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

Why isnt this spawn script working? [closed]

Asked by
EpicLilC 150
8 years ago

When the player joins, I want them to teleport to a spot in the game. Why doesn't this script work?

function onPlayerAdded(player)
    game.Players.Player:MoveTo =(Vector3.new(20.755, 28.28, -218.88))
end
game.Players.PlayerAdded:connect(onPlayerAdded)

Locked by IcyEvil, Void_Frost, and Goulstem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

3 answers

Log in to vote
4
Answered by
IcyEvil 260 Moderation Voter
8 years ago

Well :MoveTo is not a valid member of player, so this is how we are going to do it. first we will start out with the function however I think it would be easier to use an anonymous function.

game.Players.PlayerAdded:connect(function(plr)

end)

now that we have the function down we should move on to what this function Does so you are wanting to move a player on spawn to that Position but you can't move a Player, as it is not what is Inside of Workspace the thing that players use are Characters so while we no longer need to use the game.Players.plr.Character any longer we can just use plr.Character and that should work

game.Players.PlayerAdded:connect(function(plr)
plr.Character:MoveTo(Vector3.new(20.755, 28.28, -218.88))
end)

but I would much prefer myself using a CFrame on the Plrs Torso. so here is MY Method on doing it..

game.Players.PlayerAdded:connect(function(plr)
local tor = plr.Character:findFirstChild("Torso")
if tor then
tor.CFrame = CFrame.new(20.755, 28.28, -218.88)
end
end)

Don't have to do it that way but it should work much simpler.

Ad
Log in to vote
1
Answered by 8 years ago
function onPlayerAdded(player)
    game.Players.Player:MoveTo(Vector3.new(20.755, 28.28, -218.88)) --Not entirely sure, but I think your '=' was the problem
end
game.Players.PlayerAdded:connect(onPlayerAdded)
0
Still wrong, read my answer in order to understand why this is wrong, you were off just slightly. IcyEvil 260 — 8y
Log in to vote
1
Answered by 8 years ago

You dont need the equals sign. Heres how it should be

function onPlayerAdded(player)
            game.Players.Player:MoveTo(Vector3.new(20.755, 28.28, -218.88))
end
game.Players.PlayerAdded:connect(onPlayerAdded)

0
That does not work. MoveTo is not a valid member of Player DeveloperSolo 370 — 8y
0
Close, but :MoveTo like JohnTUnderwood said, is not a valid member of player, meaning you can't use ***:MoveTo*** on Players that are within game.Players IcyEvil 260 — 8y