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

I cannot change the player's jumppower?

Asked by 5 years ago

hello i am new to scripting, so i want to change the player of jumppower to the value in the leaderboard. the script looks bad but hope i can get solved

game.Players.PlayerAdded:connect(function(player)
    while wait(2) do
        local character = player.Character:WaitForChild("Humanoid")
        local jumppower = player.leaderstats.Jump.Value
        character.JumpPower = jumppower
    end
end)

here it is but it is not working. i put it in the workspace. it is a normal script.

2 answers

Log in to vote
0
Answered by 5 years ago

You should do this instead.

game.Players.PlayerAdded:connect(function(player)
    while wait(2) do
        local character = game.Workspace[player.Name]:WaitForChild("Humanoid")
    local jumpp0wer = character.JumpPower.Value
        local jumppower = player.leaderstats.Jump.Value
    jumppower = = jumpp0wer 
    end
end)
0
Workspace.Script:4: attempt to index field 'JumpPower' (a number value) A_nsonn 4 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

This should help:

game.Player.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(character)
        local hum = character:WaitForChild("Humanoid")
        hum.JumpPower= plr.leaderstats.Jump.Value
    end)
end)

then for better performance instead of using an infinite loop, you can use Changed event for the leaderstats value and then fix jump power

0
also use Connect instead of connect cause connect is deprecated g1o2r3d4a5n6 350 — 5y
0
Where should I put the script in? Workspace or StarterPlayer? LocalScript or Normal Script? A_nsonn 4 — 5y

Answer this question