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

why won't this teleport script work?

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

1 comment

0

You had many errors. Please check your spelling. ALso, it seems that you don't really know how to do that loop..

2 answers

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!

1 comment

0

thank you that helped

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.

2 comments

0

Looks like you understood him better than I did. I was a bit confused with his script.

0

thank you that helped!

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