Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem with Remote Events, all my args is shown as the Player Name how i can fix?

Asked by 4 years ago
Edited 4 years ago
--[[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.

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago

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.

0
Tysm, now i can continue my project and its right i dont need specify the player and stuff. DiogoBr34 32 — 4y
Ad

Answer this question