Hello. I am making a trading system, as you may know, trading system require a lot of client-server communication, It all went fine until I figured out a remote event isn’t being fired. I’ve tried to print something when the button is clicked, it works, I tried to print something in the beggining of the remote event handler, but it did not print it. Here are my codes:
LocalScript:
local button = script.Parent;
local function on_Click()
local player = game.Players.LocalPlayer;
local requestSender = string.split(script.Parent.Parent.Parent.TextLabel.Text, " ")[1]
script.Parent.Parent.Parent.Parent.Enabled = false
player.PlayerGui.TradePanel.Enabled = true;
player.PlayerGui.Inventory.Enabled = false;
player.PlayerGui.Trading.Enabled = false;
player.PlayerGui.Around.Inside.FirstOffer.OffererUsername.Value = player.Name
player.PlayerGui.Around.Inside.SecondOffer.OffererUsername.Value = requestSender
player.PlayerGui.TradePanel.Around.Inside.FirstOffer.Offerer.Text = string.upper(player.Name).. "'S OFFER"
player.PlayerGui.TradePanel.Around.Inside.SecondOffer.Offerer.Text = string.upper(requestSender).. "'S OFFER"
script.Parent.Parent.Parent.Parent.Enabled = false
game.ReplicatedStorage.TradeRemotes.AcceptTrade:FireServer(script.Parent.Parent.RequestSender.Value)
end;
button.MouseButton1Click:Connect(on_Click)
ServerScript:
local remoteEvent = game.ReplicatedStorage.TradeRemotes.AcceptTrade;
local function server_Event(player, requestSender)
print("Fired.")
for _, v in ipairs(game.Players:GetChildren()) do
if string.upper(v.Name) == string.upper(requestSender) then
v.PlayerGui.TradePanel.Enabled = true
v.PlayerGui.TradePanel.Around.Inside.FirstOffer.Offerer.Text = string.upper(requestSender).. "'S OFFER"
v.PlayerGui.TradePanel.Around.Inside.SecondOffer.Offerer.Text = string.upper(player.Name).. "'S OFFER"
v.PlayerGui.Inventory.Enabled = false;
v.PlayerGui.Trading.Enabled = false;
end
end
end;
remoteEvent.OnServerEvent:Connect(server_Event)
There doesn’t seem to be any errors in the code, as per me, are you sure you are checking the Server Side Output? Someone else faced a similar problem before few weeks, and this was the reason.
Could you check if the Server script itself is running at the first place till the OnServerEvent? Probably place a print statement before that Connection.
I did what you told me to do and it printed perfectly. But it seems like the remote isn’t being fired since the handler of this remote seems to be fine without errors.
This seems kind of weird to me, your best option is to check if the Remote event is even being fired or not, if not, something is probably wrong in your client code.
Also are there any errors in client/server side output?
He doesn’t need to do it in the local script since local scripts are already a part of the player. The variable example should only be a part of the local script.
Taking into consideration, it works and it does appear for the player who accepts it, but not for the player who sent the request considering the remote event isn’t being fired.
The remote event handler does not execute when I fire the remote event through the local script. Which could be understandable most likely by the reason, that the remote event isn’t being fired.
This is confusing now, I even tried testing in my studio and nothing is wrong with RemoteEvents. But you said the other player’s GUI is changing? So that means the remote event is working right, the thing is probably you aren’t on the right console tab.