Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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)
0
You should use getplayers instead of get children and you can only use moveto on the humanoid not the character kepiblop 124 — 3y
0
u can use moveto on character HappyTimIsHim 652 — 3y

1 answer

Log in to vote
1
Answered by
Rinextel 291 Moderation Voter
3 years ago
Edited 3 years ago

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

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. Rinextel 291 — 3y
0
Thanks dude! DataCordz 6 — 3y
Ad

Answer this question