Remote Event not Firing to Client

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.

Could you make a print to check if it returns on the 2nd code block? The one with print(“good”)

Edit: Just realized what you meant, one second.
Edit 2: I added in a print of “This failed” for the block of code with return, and it did not print that.

Can’t see what it is right now, I’ll let you know if I do lol. Someone will probably spot it before me.

1 Like

With the remote event located under the playergui, I guess it happened to be connecting to the wrong remote event, so I moved it to replicated storage and it works now. Thanks for the help anyways.

2 Likes

Remote events and functions should always be in ReplicatedStorage. If it is put in the StarterGui then every player will have their own different version of the event instance.

1 Like

I have been getting bugs similar where my scripting has no bugs, just the event needs to be moved around, usually for me I would have to put the event under PlayerGui instead of under Workspace.

Not sure if there are restrictions with these things. It’s possibly a Studio bug anyways.
It does say that Events need to be where both parties can see. For example: Client can not see ServerStorage.