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

why won't this teleport script work?

Asked by 10 years ago

I did this but the script just crashed! help please

spawn = spawnlocation.Postition
for i,v in pairs(game.Players:GetPlayers()) do
 name = v.name
 char = game.Workspace:FindFirstChild(name)
if char ~= nil then
char2 = char:FindFirstChild("Humanoid")
if char2 ~= nil then
char:MoveTo(spawn)
game.Lighting.RocketLauncher:Clone().Parent = v.BackPack
game.Lighting.Timebomb:Clone().Parent = v.BackPack
end
end
end
0
You had many errors. Please check your spelling. ALso, it seems that you don't really know how to do that loop.. Shawnyg 4330 — 10y

2 answers

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago
access = {"shawnyg", "bob"}
spawn = game.Workspace.SpawnLocation

game.Players.PlayerAdded:connect(function(plr)
    for i,v in pairs(access) do
        if plr.Name == v then
            tool = game.Lighting["ToolNameHere"]
            tool:clone().Parent = plr.Backpack
            --tool:clone().Parent = plr.StarterGear
            --Above is if you want it to stay with them
            plr.Character:MoveTo(spawn) --If I'm wrong with this line, add spawn.Position
        end
    end
end)

~ Did I help you? Well, help me out by bumping up my reputation/accepting my answer!

0
thank you that helped mikeinator3214 0 — 10y
Ad
Log in to vote
1
Answered by 10 years ago

Try this instead.

spawn = Vector3.new(0,0,0)--Change the 0,0,0 to the position you want the player teleported.
for i,v in pairs(game.Players:GetPlayers()) do
 name = v.name
 char = v.Character--Character is sort of a hidden value within Player, that takes you to the workspace version of that player. Handy to know.
if char ~= nil then
char2 = char:FindFirstChild("Humanoid")
if char2 ~= nil then
char.Torso.CFrame  = CFrame.new(spawn) -- Changes the CFrame of the torso, in turn teleporting the player.
game.Lighting.RocketLauncher:Clone().Parent = v.BackPack
game.Lighting.Timebomb:Clone().Parent = v.BackPack
end
end
end

If this doesn't work, tell me the error and I'll try to fix it.

0
Looks like you understood him better than I did. I was a bit confused with his script. Shawnyg 4330 — 10y
0
thank you that helped! mikeinator3214 0 — 10y

Answer this question