local plr = game.Players.LocalPlayer local char = plr.Character local UIS = game:GetService("UserInputService") local Mouse = plr:GetMouse() --------------------------------------------- local RP = game:GetService("ReplicatedStorage") local Remote = RP.FireBallRemote -------------------------------------- local Debounce = true local Key = "Z" local ButtonDown = false UIS.InputBegan:Connect(function(Input, IsTyping) if IsTyping then return end local KeyPressed = Input.KeyCode if KeyPressed == Enum.KeyCode[Key] and Debounce and char then Debounce = false ButtonDown = true Remote:FireServer(ButtonDown, Mouse.Hit,UIS) print("fired") end end)
Client
local plr = game.Players.LocalPlayer local char = plr.Character local UIS = game:GetService("UserInputService") local Mouse = plr:GetMouse() --------------------------------------------- local RP = game:GetService("ReplicatedStorage") local Remote = RP.FireBallRemote -------------------------------------- local Debounce = true local Key = "Z" local ButtonDown = false UIS.InputBegan:Connect(function(Input, IsTyping) if IsTyping then return end local KeyPressed = Input.KeyCode if KeyPressed == Enum.KeyCode[Key] and Debounce and char then Debounce = false ButtonDown = true Remote:FireServer(ButtonDown, Mouse.Hit,UIS) print("fired") end end)
Server
local UIS = game:GetService("UserInputService") Remote.OnServerEvent:Connect(function(Player,Down,HitPosition) -- code here end)