Same code from a localscript, wont work in a server script

So I had some code written in a local script, here:

local UIS = game:GetService("UserInputService")
local char = script.Parent.Parent

local keybind = Enum.KeyCode.E
local db = true
local cooldown = 10
local RemoteEvent = script.Parent.AbilityRemote

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	if not db then return end

	if input.KeyCode == keybind then
		db = false
		script.Parent.Parent.Humanoid.WalkSpeed = 45
		script.Parent.Handle.AbilitySound:Play()
		wait(4)
		script.Parent.Parent.Humanoid.WalkSpeed = 19
		wait(cooldown)
		db = true
	end
end)

But, I wanted the effects to be display for everybody, so I copied the code into a server script, but it’s not working as a server script, no errors or anything, it just does nothing, can anyone help, thanks!

1 Like

UserInputService only works on the client, you need to use remote events for this.

2 Likes

Local scripts and server scripts are VERY different.

1 Like