I made a script so that if a players walk speed is at a certain speed they lose health each second heres what I have that does not work.
local Player = game.Players.LocalPlayer if Player.Character.Humanoid.WalkSpeed >= 200 then Player.Character.Humanoid.Health = 85 if Player.Character.Humanoid.WalkSpeed >= 300 then Player.Character.Humanoid.Health = 65 end end
This is in my starterpack as a local script.
You need to put the check in a loop, and subtract from their health constantly. Also, be consistent and be wary of errors.
local Player=Game:service'Players'.localPlayer; local RunService=Game:service'RunService'; local HighDamage=5;--// If they are at a certain height local MaxedDamage=10; local HighSpeed=200; local MaxedSpeed=300; Spawn(function()--// Spawns a new co-routine. while(true)do local Humanoid=Player.Character and Player.Character:findFirstChild'Humanoid'; if(Humanoid and Humanoid:isA'Humanoid')then --// Checks if the humanoid exists, --// and is actually a humanoid. (prevents errors from name collision) local Speed=Humanoid.WalkSpeed; local DamageTaken=Speed >= HighSpeed and ( Speed < MaxedSpeed and HighDamage or MaxedDamage ) or 0;--// Aligns damage with speed. Humanoid:TakeDamage( DamageTaken );--// No harm in doing it if it's 0. end; wait(5); end; end)