I’m working on a trading system, which requires a lot of interaction between client and client. I read that you need to fire to the server first, and then fire to a different client, so that’s how I have it set up. It fires to the server, and then it prints “Good” which shows that the line before it worked and should have fired to a different client, but it is not picked up on the OnClientEvent.
This is the button that you press to send a trade to someone.
player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local PlayerToSend = script.Parent.Parent.Parent.PlayerName.Text
if PlayerToSend ~= player.Name then
if game.Players:FindFirstChild(PlayerToSend) then
script.Parent.Parent.Parent.Parent.TradePrompt:FireServer(PlayerToSend)
else
return
end
else
return
end
end)
This is the one that picks up the FireServer. And yes, it does properly print the two names.
script.Parent.TradePrompt.OnServerEvent:Connect(function(player, PlayerToSend)
print(PlayerToSend)
print(player.Name)
if game.Players:FindFirstChild(PlayerToSend) then
script.Parent.TradePrompt:FireClient(game.Players[PlayerToSend], PlayerToSend, player.Name)
print("Good")
else
return
end
end)
And lastly, this is the one that seems to not be working. It does not print the “Connected event”
script.Parent.TradePrompt.OnClientEvent:Connect(function(player, PlayerWhoSent)
print("Connected event")
if game.Players:FindFirstChild(PlayerWhoSent) then
player.PlayerGui.MainGUIs.PromptBox.Visible = true
player.PlayerGui.MainGUIs.PromptBox.TextLabel.Text = PlayerWhoSent.." has sent you a trade!"
local content, isready = game.Players:GetUserThumbnailAsync(PlayerWhoSent.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
player.PlayerGui.MainGUIs.PromptBox.PlayerImage.Image = content
else
return
end
end)
And before anyone points it out, Ik it can be easily exploited, but this is just a rough write up to see if the concept is there. And I have been using Test mode with me playing as 2 players if anyone was wondering.