top of page
Search

Open Source Run System

  • Writer: Asporus
    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.



 
 
 

Recent Posts

See All
Open Source Leaderstats Script

Leaderstats are very simple, and most developers that have developed for at least a week have learned them. Some new people, though,...

 
 
 
Open Source Camera Manipulation GUI

For this script, you will need a part named "CamPart" or you can change the variable to your desired part in workspace. Make sure the...

 
 
 

Comments


Post: Blog2_Post
  • Facebook
  • Twitter
  • LinkedIn

©2020 by Asporus. Open Source Script Library.

bottom of page