I have a folder that contains 1 Teleports 2. Triggers for the teleports but i always get this error even tho non of the things were misspell and it was in the same exact folder. That it was supposed to be in.
function CabinTeleportTouched(hit) local players = game.Players:GetChildren() for i = 1,#players do game.Workspace.Triggers.CabinTrigger:Destroy() wait(3) players[i].Character:MoveTo(game.Workspace.TeleportPoints.CabinTeleport1.Position) wait() script.Disabled = true end end game.Workspace.Triggers.CabinTrigger.Touched:Connect(CabinTeleportTouched)
Hello DataCardz!
There are a few issues with your script, here I'll go over each one and what I'd do.
local players = game.Players:GetChildren()
ROBLOX has a specific function to get players, rather than having to do GetChildren() of the players. You could do what's listed below instead.
local players = game:GetService('Players'):GetPlayers()
Moving onto line 04.
game.Workspace.Triggers.CabinTrigger:Destroy()
This script will try to run before Triggers, or CabinTrigger is loaded in. You should use :WaitForChild() just to be safe. Refer to the link for a better explanation on :WaitForChild().
Next up,
players[i].Character:MoveTo(game.Workspace.TeleportPoints.CabinTeleport1.Position)
Again, you should be using a WaitForChild() to make the script wait for CabinTeleport1. However, from the looks of it, you're destroying CabinTrigger before teleporting the player. Additionally, :MoveTo() you can not use :MoveTo() on the players character model itself. You're going to have to get the Players character humanoid and use :MoveTo().
players[i].Character:WaitForChild('Humanoid'):MoveTo(game.Workspace.TeleportPoints.CabinTeleport1.Position)
If this still does not work you need to ensure that: A) CabinTeleport1 is not nil / is inside of the TeleportPoints folder. B) This is a server script C) This script is inside somewhere the server access / run