So, I am wanting to improve this Script which finalizes the Players Speed and Animation. Another key factor is that for Mobile there’d be a “RunBind”. I also need the Mobile RunBind to enhance with the Stamina System so that the game can comprehend properly to its extent.
Here is the Kit for the Run & Stamina System: System.rbxm (10.6 KB)
Because when I hold Shift to Run the Stamina will work but when I hold the “RunBind” on Mobile testing service the Stamina doesn’t comprehend with the Stamina System.
-- Player Run System 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://15411322421"
RAnimation = Humanoid:LoadAnimation(RunAnimation)
Running = false
function Handler(BindName, InputState)
if InputState == Enum.UserInputState.Begin and BindName == "RunBind" then
Running = true
Humanoid.WalkSpeed = 25
elseif InputState == Enum.UserInputState.End and BindName == "RunBind" then
Running = false
if RAnimation.IsPlaying then
RAnimation:Stop()
end
Humanoid.WalkSpeed = 10
end
end
Humanoid.Running:connect(function(Speed)
if Speed >= 10 and Running and not RAnimation.IsPlaying then
RAnimation:Play()
Humanoid.WalkSpeed = 25
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)
game:GetService("ContextActionService"):SetImage("RunBind", "rbxassetid://9525535512")
Well, you see I am trying to make the Run System enhance with the Stamina System so when the Player would to interact with the “RunBind” the Stamina will reduce just like when it does for “Shift to Run”.
@ZxCryB
Maybe if possible do you think you could compromise the Run System Script into the Stamina Handler Script so then it will work in a total function, as in the comparison from having two Scripts defying the Players Movement & Speed. I need the “RunBind” to comprehend to the exact extent in its way of interacting with the “RunBind” so it can have the same affect with the Stamina System. Does that make sense or not?