Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Im Getting this Spam in my error "CabinTeleport1 is not a valid member of Folder" is studio broken?

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)

2 comments

0

You should use getplayers instead of get children and you can only use moveto on the humanoid not the character

0

u can use moveto on character

1 answer

✓ Accepted answer

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

2 comments

1

Also please note that :MoveTo() will make the player walk to that position. I believe you're wanting to teleport the player. If that's the case, you should change the HumanoidRootPart.CFrame to the CabinTeleport1.CFrame.

0

Thanks dude!

This discussion is preserved as it was. New answers, comments, and votes are closed.