Random respawn

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Try this and clear all spawn points and set new ones
Code:
command /setspawn:
    trigger:
        add location of player to {spawnpoint::*}
 
command /unsetspawn:
    trigger:
        loop indexes of {spawnpoint::*}:
            if distance between player's location and {spawnpoint::%loop-value%} < 2:
                remove {spawnpoint::%loop-value%} from {spawnpoint::*}
 
command /unsetallspawn:
    trigger:
        clear {spawnpoint::*}
 
on respawn:
    teleport player to a random location out of {spawnpoint::*}
Code:
on player respawn:
    wait 1 tick
    if {sleeproll::%event-player's UUID%::*} is set:
        create new gui with chest inventory with 3 rows named "Sleeping Bags"
        loop integers between 1 and size of {sleeproll::%event-player's UUID%::*}:
            if loop-number < 27:
                set {_loopv} to loop-number
                set {_bedname} to {sleeproll::%event-player's UUID%::%{_loopv}%}'s location
                if loop-number = 1:
                    set {_bedname} to "&7your most recent bed @ %{_bedname}%"
                edit gui last gui:
                    make gui loop-number - 1 with any bed named "%{_bedname}%":
                        teleport event-player to {sleeproll::%event-player's UUID%::%{_loopv}%}
        open gui last gui to event-player
 
command /clearbeds [<player=%event-player%>]:
    trigger:
        clear {sleeproll::%arg 1's UUID%::*}
 
on rightclick:
    if clicked block is lime carpet:
        if {sleeproll::%event-player's UUID%::*} does not contain event-block:
            set {sleeproll::%event-player's UUID%::*} to reversed {sleeproll::%event-player's UUID%::*}
            message "You have placed a Sleeping Bag at: %event-location%" to event-player
            add event-block to {sleeproll::%event-player's UUID%::*}
            set {sleeproll::%event-player's UUID%::*} to reversed {sleeproll::%event-player's UUID%::*}
 
on break of lime carpet:
    loop all the offline players:
        if {sleeproll::%loop-offline player's UUID%::*} does not contain event-block:
            loop integers between 1 and size of {sleeproll::%loop-offline player's UUID%::*}:
                if event-block's location is {sleeproll::%loop-offline player's UUID%::%loop-value-2%}'s location:
                    delete {sleeproll::%loop-offline player's UUID%::%loop-value-2%}
                    if size of {sleeproll::%loop-offline player's UUID%::*} < 2:
                        clear {sleeproll::%loop-offline player's UUID%::*}
I currently have this config for sleeping bags, and on death, it opens a gui with the sleeping bags that u have. Could you please help me to add a button for the random respawn for the 4 spawns ? Like you press the button and then u respawn on 1 of those 4 locations.
[doublepost=1621715251,1621715060][/doublepost]
Wdym with "same location"? Do you respawn at the same location every time or at the default minecraft spawn point?

Try adding a delay
Code:
on respawn:
    wait 0.5 seconds
    teleport player to a random location out of {spawnpoint::*}
So when I kill myself, I am spawning to the /spawn location where the world has the spawn.
 
do you have any other plugins or skripts running that make you respawn at a location? think essentials spawn, or something?

maybe add a "wait 2 ticks" in the 'on respawn:' part. as i know GUI also like to not open if you try to do it on respawn.
 
do you have any other plugins or skripts running that make you respawn at a location? think essentials spawn, or something?

maybe add a "wait 2 ticks" in the 'on respawn:' part. as i know GUI also like to not open if you try to do it on respawn.
Yes I have essentials. Going to try right now the wait 2 ticks
[doublepost=1621720696,1621720640][/doublepost]I will remove essentials too for a sec to see if anything changes
[doublepost=1621721295][/doublepost]
do you have any other plugins or skripts running that make you respawn at a location? think essentials spawn, or something?

maybe add a "wait 2 ticks" in the 'on respawn:' part. as i know GUI also like to not open if you try to do it on respawn.
Still not working even that I've removed essentials and added 2 ticks.
 
Status
Not open for further replies.