--[[Local Script]]-- player = game:GetService("Players").LocalPlayer cas = game:GetService("ContextActionService") rep = game:GetService("ReplicatedStorage") userEvents = rep:WaitForChild("UserEvents") events = {} events.Punch = userEvents:WaitForChild("Punch") cooldowns = {} cooldowns.Punch = {["debounce"] = false, ["Time"] = 1} info = {} info.Punch = {["Side"] = true} functions = {} functions.Input = function(action, state, InputObj) if InputObj.UserInputType == Enum.UserInputType.MouseButton1 then if cooldowns.Punch.debounce then return end cooldowns.Punch.debounce = true functions.Punch() wait(cooldowns.Punch.Time) cooldowns.Punch.debounce = false end end functions.Punch = function() local Punch = events.Punch if info.Punch.Side then Punch:FireServer(player, info.Punch.Side) info.Punch.Side = false else if not info.Punch.Side then Punch:FireServer(player, info.Punch.Side) info.Punch.Side = true end end end cas:BindAction("Punch", functions.Input, false, Enum.UserInputType.MouseButton1)
--[[Script]]-- rep = game:GetService("ReplicatedStorage") standuserEvents = rep:WaitForChild("StandUserEvents") punchEvent = userEvents:WaitForChild("Punch") punchEvent.OnServerEvent:Connect(function(player, side) print(side) end)
I did alot of things like changing args positions re-writing the both scripts but nothing worked.
The first argument will always be imposed as the Client that fires the Remote, this situation is only valid for FireServer
. You also fired the Player again as a first argument which as can be seen from my first sentence is unnecessary. The only situation upon where a Player must be passed as an argument via a Remote is FireClient
. Altogether, the OnServerEvent
signal is receiving the Local Player twice, which is stored in Player
and Side
. Simply remove the first argument "Player" from FireServer
.