I have a script in StarterCharacterScripts with this code
person = script.Parent personspeed = person.Humanoid.WalkSpeed while true do print(personspeed) wait(1) end
It prints "20" when I run the game, but when i change the WalkSpeed of my character it will continue to print "20". Any help?
person = script.Parent personspeed = person.Humanoid.WalkSpeed while true do print(personspeed) wait(1) script.Parent.Script:Destroy() end
I might of fixed the problem. You forgot to put "script.Parent.Script:Destroy()" Please let me know if this does not work.
You may be better off using .Changed to call a function whenever the WalkSpeed changes. The parameter returned by .Changed is the property of the Instance that was changed. See here: https://developer.roblox.com/en-us/api-reference/event/Instance/Changed
Example:
local person = script.Parent -- also it's good practice to include "local" in your variables. local Humanoid = person.Humanoid Humanoid.Changed:Connect(function(WhatWasChanged) if WhatWasChanged == Humanoid.WalkSpeed then print(Humanoid.WalkSpeed.Value) end end)