local input = false
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
print("Is running")
if input == true then return end
input = true
game.ReplicatedStorage.Run:FireServer("run")
end
end)
uis.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
input = false
game.ReplicatedStorage.Run:FireServer("walk")
end
end)
Script >> ServerScriptService
game.ReplicatedStorage.Run.OnServerEvent:Connect(function(plr, inptype)
if not workspace:FindFirstChild(plr.Name) then return end
if inptype == "run" then
workspace[plr.Name].Humanoid.WalkSpeed = 35
end
if inptype == "walk" then
workspace[plr.Name].Humanoid.WalkSpeed = 16
end
end)
Sorry i didn’t have an explanation of how it works since i’m on a phone and i’m used to using my pc.
Edit: Add a remoteevent in Replicatedstorage and name it “Run”
it’s all fine i also recommend watching @Alvin_Blox’s scripting tutorials they are really helpful. anyways go in the part where it changes walkspeed to 35 and add a new line and type this
local character = workspace[plr.Name]
local animation = Instance.new("Animation")
local animationid = type animation id here
animation.AnimationId = "rbxassstid://"..animationid
character.Humanoid:LoadAnimation(animation)
Also if it matters in your game, you should make checks where needed if they are allowed to sprint or not. As the above script example stands, exploiters can send “run” regardless if they are pressing shift or not, effictively giving them infinite “run” time.
Hello peanut brain is back, I hate to annoy you but…
game.ReplicatedStorage.Run.OnServerEvent:Connect(function(plr, inptype)
if not workspace:FindFirstChild(plr.Name) then return end
if inptype == "run" then
workspace[plr.Name].Humanoid.WalkSpeed = 35
local character = workspace[plr.Name]
local animation = Instance.new("Animation")
local animationid = type animation id here
animation.AnimationId = "rbxassstid://5356324783"..animationid
character.Humanoid:LoadAnimation(animation)
end
if inptype == "walk" then
workspace[plr.Name].Humanoid.WalkSpeed = 16
end
end)
I want to know want i’m doing wrong. I will learn from mistakes