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

What's wrong with this script?

Asked by
Zerio920 285 Moderation Voter
10 years ago
local player = game.Players.LocalPlayer
    player.CharacterAdded:connect(function(char)
humanoid = player.Character:WaitForChild("Humanoid")
    if humanoid.Jump == true then
        player:LoadCharacter()
    end
    end)

I put this in a LocalScript. It's supposed to check if you're able to jump, and if you are, to reload your character. Dunno if this is the right way to do it, but it doesn't seem to work for some reason.

2 answers

Log in to vote
1
Answered by 10 years ago

Try using Changed instead of CharacterAdded. Changed is useful for seeing if there is a change within the property of an object.

local player = game.Players.LocalPlayer
humanoid = player.Character:WaitForChild("Humanoid")
humanoid.Changed:connect(function(property)
    if property == "Jump" and humanoid.Jump == true then
        player:LoadCharacter()
    end
end)
Ad
Log in to vote
0
Answered by 10 years ago

Maybe u need to loop it re-do the script but make it local in the player backpack

Like this

While wait() do local player = game.Players.LocalPlayer

humanoid = player.Character:FindFirstChild("Humanoid")

if humanoid.Jump == true then

    player:LoadCharacter()

end

end)

Or if u don't want that use this

local player = game.Players.LocalPlayer ---This wrong theres no local player in game.Player yet when player enters game so do this

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

Wait(2) --- waits for the player to spawn

humanoid = player.Character:FindFirstChild("Humanoid") --- finds the player humanoid

if humanoid.Jump == true then

    player:LoadCharacter()

end

end)

I did it , it works try it u will see

Answer this question