Ok, So I self-debugged it and it does change the value, BUT not the text. It is getting a little annoying so I just came here to ask a question about it.
local plr = game.Players.LocalPlayer local sp = Instance.new("IntValue") sp.Value = 100 plr.PlayerGui.MainUI.Display.SprintPower.Text = "Sprint Power: " ..sp.Value sp.Parent = plr while true do wait() function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then local character = plr.Character if character then local hum = character:WaitForChild"Humanoid" if hum then hum.WalkSpeed = 26 end else print("no character") end sp.Value = 100 wait(1) sp.Value = 50 wait(10) sp.Value = 0 if sp.Value == 0 then plr.Character.Humanoid.WalkSpeed = 16 end end end game:GetService("UserInputService").InputBegan:connect(onKeyPress) function onKeyPressEnd(inputObject, gameProcessedEvent) local character = plr.Character if character then local hum = character:WaitForChild"Humanoid" if hum then hum.WalkSpeed = 16 end else print("no character") end sp.Value = 50 wait(1) sp.Value = 100 end game:GetService("UserInputService").InputEnded:connect(onKeyPressEnd) end
If anyone knows the error please answer this! :)
Try this, this happened to me while making a gui for my place, I'm pretty sure it's because the script gets the sp value when it fires, and doesn't re-check when it changes, the solution was adding an extra function to detect when the value changes and update the text.
local plr = game.Players.LocalPlayer local sp = Instance.new("IntValue") sp.Value = 100 plr.PlayerGui.MainUI.Display.SprintPower.Text = "Sprint Power: " ..sp.Value sp.Parent = plr while true do wait() function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then local character = plr.Character if character then local hum = character:WaitForChild"Humanoid" if hum then hum.WalkSpeed = 26 end else print("no character") end sp.Value = 100 wait(1) sp.Value = 50 wait(10) sp.Value = 0 if sp.Value == 0 then plr.Character.Humanoid.WalkSpeed = 16 end end end game:GetService("UserInputService").InputBegan:connect(onKeyPress) function onKeyPressEnd(inputObject, gameProcessedEvent) local character = plr.Character if character then local hum = character:WaitForChild"Humanoid" if hum then hum.WalkSpeed = 16 end else print("no character") end sp.Value = 50 wait(1) sp.Value = 100 end game:GetService("UserInputService").InputEnded:connect(onKeyPressEnd) end sp.Changed:connect(function(NewValue) plr.PlayerGui.MainUI.Display.SprintPower.Text = "Sprint Power: " ..sp.Value end)