Just the Mobile thank you, I’ve already got the PC usage patched.
actually wait… both thank you, I’ve just realised
I do apologies for the inconvenience, sorry
Alright try this it makes it so that players can start running if they are standing still and when they do start running if they stop moving they will stop runninng
-- PlayerRunSystem Script
-- PC usage for StaminaSystem
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid
local anim= Instance.new("Animation")
anim.AnimationId = "rbxassetid://15411322421"
local RunAnimation =Humanoid:LoadAnimation(anim)
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift and Humanoid.MoveDirection.Magnitude > 0 then
Character.Humanoid.WalkSpeed = 25
RunAnimation:Play()
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 10
RunAnimation:Stop()
end
end)
-- Mobile usage for StaminaSystem
player:WaitForChild("PlayerGui").StaminaGui.Holder.Sprint.MouseButton1Down:Connect(function()
if RunAnimation.IsPlaying and Humanoid.MoveDirection.Magnitude > 0 then
RunAnimation:Stop()
else
RunAnimation:Play()
end
-- When Player clicks "SprintButton" the Animation will stop and the Players Speed will reduce
end)
game:GetService("RunService").Heartbeat:Connect(function()
if Humanoid.MoveDirection.Magnitude < 0 and RunAnimation.IsPlaying then
RunAnimation:Stop()
Character.Humanoid.WalkSpeed = 10
end
end)
Is this supposed to cancel the Run Animation if the Player isn’t moving? Because, I just tested it for PC and it didn’t make the Animation cancel so I was holding “Shift” and not moving whilst the Animating was running.
Wait so its allowing you to run in place?
Do you think it will be easier if I would to send it all in a File?
yeah it is executing while the speed is remaining neutral = 0
Do you have any other code doing sprinting because that definitely should be working
Yeah I do, that is why I mentioned.
Replace the stamina system with this
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local SoundFX = script.RunSound
local StaminaGui = script.Parent
local Holder = StaminaGui:WaitForChild("Holder")
local Bar = Holder:WaitForChild("Bar")
local UIS = game:GetService("UserInputService")
local Stamina = script.Stamina
local isRunning = false
local gotTired = false
local mobileToggle = false
local function toggleSprint(state: boolean)
if state and Stamina.Value >= 1 and not gotTired and humanoid.MoveDirection.Magnitude > 0 then
humanoid.WalkSpeed = 25
SoundFX:Play()
script.InSprint.Enabled = true
script.OutSprint.Enabled = false
else
humanoid.WalkSpeed = 10
SoundFX:Stop()
script.InSprint.Enabled = false
script.OutSprint.Enabled = true
end
end
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
toggleSprint(true)
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
toggleSprint(false)
end
end)
Holder.Sprint.MouseButton1Down:Connect(function()
mobileToggle = not mobileToggle
toggleSprint(mobileToggle)
end)
script.Tired.Event:Connect(function()
if Stamina.Value <= 1 then
humanoid.WalkSpeed = 10
script.InSprint.Enabled = false
script.OutSprint.Enabled = true
gotTired = true
wait(1)
gotTired = false
end
end)
while true do
wait()
game:GetService("TweenService"):Create(Bar, TweenInfo.new(0.075, Enum.EasingStyle.Quint), {Size = UDim2.new(Stamina.Value / 100, 0, 1, 0)}):Play()
end
the Run Animations plays on the spot when the Player would to move then stay still while holding Shift. This is for PC
not being rude and all but the Mobile has completely broke.
Yeah it probably wouldve been best if you just put them in 1 script because there handling things that depend on each other
I would but I don’t know how lol.
Where did you get these scripts from??
I used free Model but I just customized them in benefits.
Very different to free Model considering I did tweaking.
@astraIboy would it possible to make the Mobile Run Animation and PC Run Animation hold when Player Speed is 0.