i made a script that makes me 9 walkspeed when i reach low health. but im still able to sprinting someone please help how i disable the script when i reach low health (etc. 30 health) (when health regens script will be able again)
The Running Script :
local Player = game.Players.LocalPlayer local Character = workspace:WaitForChild(Player.Name) local Humanoid = Character:WaitForChild('Humanoid') local RunAnimation = Instance.new('Animation') RunAnimation.AnimationId = 'rbxassetid://11321538517' -- Animation ID here. RAnimation = Humanoid:LoadAnimation(RunAnimation) Running = false function Handler(BindName, InputState) if InputState == Enum.UserInputState.Begin and BindName == 'RunBind' then Running = true Humanoid.WalkSpeed = 50 elseif InputState == Enum.UserInputState.End and BindName == 'RunBind' then Running = false if RAnimation.IsPlaying then RAnimation:Stop() end Humanoid.WalkSpeed = 16 end end Humanoid.Running:connect(function(Speed) if Speed >= 10 and Running and not RAnimation.IsPlaying then RAnimation:Play() Humanoid.WalkSpeed = 30 elseif Speed >= 10 and not Running and RAnimation.IsPlaying then RAnimation:Stop() Humanoid.WalkSpeed = 10 elseif Speed < 10 and RAnimation.IsPlaying then RAnimation:Stop() Humanoid.WalkSpeed = 10 end end) Humanoid.Changed:connect(function() if Humanoid.Jump and RAnimation.IsPlaying then RAnimation:Stop() end end) game:GetService('ContextActionService'):BindAction('RunBind', Handler, true, Enum.KeyCode.LeftShift)
Hi, your going to want to use an if
statement and then disable the script by using Enabled
code.
example
if Humanoid.WalkSpeed = 10 then script.Parent.Enabled = false
This is an example of how. It probably won't work with your code just an example.
Also I think you can use <>
to set less than or more than.
Hope this helps!!