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

Tp script not working?

Asked by
awfulszn 394 Moderation Voter
9 years ago

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
0
Are there any errors in the console? Teeter11 281 — 9y
0
yes: Workspace.Tp script:3: 'then' expected near '=' awfulszn 394 — 9y

1 answer

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
9 years ago

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)
0
Some-one should have thought twice before downvoting. woodengop 1134 — 9y
0
You need two equal signs for comparisons Perci1 4988 — 9y
Ad

Answer this question