|
Could anyone tell me what's wrong with this script. After the player has died three times, he/she/'it' does not teleport.
*Error: Unable to cast instance to int (line 14)
-------------------------------------------------------------------------------------
local destinationID = #########
lives = 3
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(loaded)
local human = loaded:WaitForChild("Humanoid")
if human then
human.Died:Connect(function(dead)
lives = lives - 1
end)
if lives <= 0 then
game:GetService("TeleportService"):Teleport(human, destinationID)
end
end
end)
end) |
|
|
The Teleport function's 1st argument should be a player, not a humanoid instance
Also, Died event of the Humanoid instance doesn't have anything fired to it. |
|
|
Changed it a little, although I'm afraid that I do not understand what you mean with your second line.
local destinationID = #######
lives = 3
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(loaded)
local human = loaded:WaitForChild("Humanoid")
if human then
human.Died:Connect(function()
lives = lives - 1
end)
if lives <= 0 then
game:GetService("TeleportService"):Teleport(player, destinationID)
end
end
end)
end) |
|
K7QJoin Date: 2013-03-23 Post Count: 5546 |
local destinationID = #######
lives = 3
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(loaded)
local human = loaded:WaitForChild("Character")
if human then
human.Died:Connect(function()
lives = lives - 1
end)
if lives <= 0 then
game:GetService("TeleportService"):Teleport(player, destinationID)
end
end
end)
end)
try dat might not work though. |
|
|
The error on line 14 is now gone, however there's one over here v
And the player does not teleport
Infinite yield possible on 'milanomaster:WaitForChild("Character")' (line 7)
|
|
|
K7QJoin Date: 2013-03-23 Post Count: 5546 |
local destinationID = #######
lives = 3
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(loaded)
local human = loaded.Humanoid:WaitForChild("Character")
if human then
human.Died:Connect(function()
lives = lives - 1
end)
if lives <= 0 then
game:GetService("TeleportService"):Teleport(player, destinationID)
end
end
end)
end)
try that |
|
|
Tried 'MoveTo' instead of 'Teleport' neither that works and the yield is still there. |
|
K7QJoin Date: 2013-03-23 Post Count: 5546 |
on the second if statement, use elseif instead of just if and get rid of the end in the middle |
|
|
Hmm.. when I try to remove the 'end)' in the middle, I keep getting red lines. |
|
|
K7QJoin Date: 2013-03-23 Post Count: 5546 |
remove the end and turn the second elseif statement into if
like this
script.Parent:Changed.connect(function()
if.Parent.FindFirstChild('BooleanValue') == true then
for i,v in pairs (game.Players:GetPlayers())
v:Kick("Reason here")
end
end
|
|
K7QJoin Date: 2013-03-23 Post Count: 5546 |
lmao sorry i put this in the wrong thread |
|