local main = script.Parent
local walkbtn = main.EnterTextBtn
local jumpbtn = main.EnterTextBtn2
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
local amount = main.Amount
walkbtn.MouseButton1Down:connect(function()
humanoid.WalkSpeed = amount.Text
end)
jumpbtn.MouseButton1Down:connect(function()
humanoid.JumpPower = amount.Text
end)
✓ ANSWER ACCEPTED
if a character dies my script does not work please help?
1 answer
✓ Accepted answer
I can't say for sure because PlayerGui should be reset on death anyways but I am assuming that it is erroring because you are declaring the humanoid variable one time. After the player dies, their character is deleted and respawned which means that the humanoid value is now nil
local main = script.Parent
local walkbtn = main.EnterTextBtn
local jumpbtn = main.EnterTextBtn2
local player = game.Players.LocalPlayer
local amount = main.Amount
walkbtn.MouseButton1Down:connect(function()
if player.Character and player.Character:FindFirstChildOfClass("Humanoid") then
player.Character:FindFirstChildOfClass("Humanoid").WalkSpeed = tonumber(amount.Text)
end
end)
jumpbtn.MouseButton1Down:connect(function()
if player.Character and player.Character:FindFirstChildOfClass("Humanoid") then
player.Character:FindFirstChildOfClass("Humanoid").JumpPower = tonumber(amount.Text)
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
how would i fix this then?
Ive edited my response with a possible fix