When i fire a remote event it will fire once, but if i try to fire it again it wont fire.
My code: – Local Script
local Event = game.ReplicatedStorage.Events.TradeRequest
local Player = game.Players:GetPlayerByUserId(script.Parent.Parent.Parent.Parent.Player.Value)
local LocalPlayer = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
Event:FireServer(Player,LocalPlayer)
end)
The code that receves the request: – server script
game.ReplicatedStorage.Events.TradeRequest.OnServerEvent:Connect(function(Player,LocalPlayer)
script.Parent.Visible = true
script.Parent.Desc.Text = LocalPlayer.Name.." sent you a trade request!"
end)
FireServer automatically takes the Player [who fired the event], which means you don’t have to put any argument that relats to the local player itself.
So what happens accordingly to your adjustments,
1st argument in FireServer is equal to 1st in OnServerEvent
2nd argument in FireServer is equal to 2nd in OnServerEvent
And that’s a problem, why?
Because:
1-OnServerEvent’s first argument is always the Player.
2-As I said before, FireServer automatically takes the Player as 1st argument.
Note
If you have 1+ arguments in FireServer event, on the server [OnServerEvent], you’ll have to put that amount of arguments BUT plus 1[which is the first one to be put, which is the Player].
--Server
game.ReplicatedStorage.Events.TradeRequest.OnServerEvent:Connect(function(Player,PlayerID)
script.Parent.Visible = true
script.Parent.Desc.Text = Player.Name.." sent you a trade request!"
end)
--Client
local Event = game:GetService("ReplicatedStorage").Events.TradeRequest
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerID = LocalPlayer.UserId
script.Parent.MouseButton1Click:Connect(function()
Event:FireServer(PlayerID)
end)