Skript to teleport in the point of view of another player

  • 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 comminuty!

    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!

NilremYT

Member
Mar 28, 2024
10
0
1
23
hey im quite new with the hole coding thing but i wanted to make it so on my server that staff member can teleport to players and that straight up in the point of view of the player like that you instanly spectate them
 
hey im quite new with the hole coding thing but i wanted to make it so on my server that staff member can teleport to players and that straight up in the point of view of the player like that you instanly spectate them
do you just want me to give you the code or just tell you how to do it?
 
both i want the code and i want a little explaining of how it exactly works


command spectate [<player>]:
permission: skript.spectate.use
trigger:
if arg-1 is set:
delete {spectating::%player's uuid%::*}
hide player from all players
set {spectating::%player's uuid%::%arg-1's uuid%} to true
send "&aSpectating %arg-1%!" to player
while {spectating::%player's uuid%::%arg-1's uuid%} is true:
hide player from all players
teleport player to arg-1
wait 0.1 seconds
else:
delete {spectating::%player's uuid%::*}
reveal player for all players

how it works is when the player runs the command and uses a player value it will delete the player they are spectating (if they are spectating as of then) then it will hide the player (this will remove them from the tablist and disable them from being autofillable from "<player>" command things then it will set a variable then it will say "Spectating (player)!" to the executor then while they are spectating it will teleport them to the player repeatedly and if you dont input a player value It will just stop having you spectate
 
Code:
command spectate [<player>]:
    permission: skript.spectate.use
    trigger:
        if arg-1 is set:
            delete {spectating::%player's uuid%::*}
            hide player from all players
            set {spectating::%player's uuid%::%arg-1's uuid%} to true
            send "&aSpectating %arg-1%!" to player
            while {spectating::%player's uuid%::%arg-1's uuid%} is true:
                hide player from all players
                teleport player to arg-1
                wait 0.1 seconds
        else:
            delete {spectating::%player's uuid%::*}
            reveal player for all players

is the code in a better format
 
Code:
command spectate [<player>]:
    permission: skript.spectate.use
    trigger:
        if arg-1 is set:
            delete {spectating::%player's uuid%::*}
            hide player from all players
            set {spectating::%player's uuid%::%arg-1's uuid%} to true
            send "&aSpectating %arg-1%!" to player
            while {spectating::%player's uuid%::%arg-1's uuid%} is true:
                hide player from all players
                teleport player to arg-1
                wait 0.1 seconds
        else:
            delete {spectating::%player's uuid%::*}
            reveal player for all players

is the code in a better format
thx for the help :emoji_slight_smile: