Open Source Run System
- Asporus
- Aug 9, 2020
- 1 min read
This is a running system using the service known as "UserInputService". UserInputService, (abbreviated as UIS), practically detects input from the client.
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local CanRun = Player:WaitForChild("CanRun")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if CanRun.Value == true then
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://5431913931"
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if CanRun.Value == true then
CanRun.Value = false
Character.Humanoid.WalkSpeed = 16
PlayAnim:Stop()
local Humanoid = Character:WaitForChild("Humanoid")
wait(1)
CanRun.Value = true
end
end
end)
Thats the full script. All functional, and etc.
Just so your aware, you need to use a script where it inserts a boolvalue into the player.
Make a script in ServerScriptService and put this code into it:
local CanRun = Instance.new("BoolValue",game.Players.LocalPlayer)
CanRun.Name = "CanRun"
CanRun.Value = true
That makes the script work, or else there would be multiple errors in the output bar as the system couldnt find the value CanRun inside of the player object.
Comments