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

Tp script not working?

What I want is, when my timer gets to zero, they get tp'd to a different map, but for some reason it is not working, they are both in different scripts. My timer script works though.

TP SCRIPT

while true do
local players = game.Players:GetPlayers()
if game.Workspace.Message.Text = "0" = true do
players.Character:MoveTo(game.Workspace.Map2.Position)
end

TIMER SCRIPT

print "Mosski123's timer script has loaded..."
wait(2)
print "Starting timer..."
wait(2)
print "Timer started..."
while true do -- While true do statement.
for test1 = 60, 1, -1 do
test2 = Instance.new("Hint", workspace)
test2.Text = "This current countdown has " ..test1.. " seconds left."
 wait(1)
game.Workspace.Message:remove()
end
end

2 comments

0

Are there any errors in the console?

0

yes: Workspace.Tp script:3: 'then' expected near '='

1 answer

✓ Accepted answer

H@ppy to Help

  • if is incorrect
  • getting the player incorrectly
amount=0
if amount==0 then -- must have a then
	print'0'
end

This prints 0 because the amount is 0, if I had amount=1 the script will print false or nil. If you want to compare between 2 numbers then we would use the Less than and More than symbol.

amount=1
if amount<2 then
	print'too small'
end
  • getting the player correctly

if you're accessing the player through a localscript then you use the localplayer

local player=game.Players.LocalPlayer

this will only work on a localscript, now for a script(if you are using one), you could by using the PlayerAdded event.

game.Players.PlayerAdded:connect(function(player) -- the player that entered
	print(player.Name)
end)

2 comments

0

Some-one should have thought twice before downvoting.

0

You need two equal signs for comparisons

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