So I've made the GUI and all, you can click trade and if you click trade it'll send the person you're trying to trade with a Frame saying that somebody wants to trade, but I can't seem to get the other player's PlayerGui. What I thought would fix it was to fire a RemoteEvent from the client to the server, then the server gets the player's PlayerGui and sends it back to the client, but it sends "nil" instead of the GUI. I've even printed if it gets the GUI and it does, but then it sends "nil" instead of the GUI. Please help...

Server script:

game.ReplicatedStorage.RemoteEvents.TradeEvents.GetPlayerGui.OnServerEvent:Connect(function(player,playerToTradeWith)
	
	local realPlayer
	
	for _,possiblePlayer in pairs(game.Players:GetPlayers()) do
		
		if possiblePlayer.Name == playerToTradeWith then
			
			realPlayer = possiblePlayer
			break
		end
	end
	
local playerGui = realPlayer:FindFirstChild("PlayerGui")	
	
	game.ReplicatedStorage.RemoteEvents.TradeEvents.GetPlayerGui:FireClient(player,playerGui)
end)

Client script:

script.Parent.MouseButton1Down:Connect(function()
	
	local player = game.Players.LocalPlayer
	local playerText = script.Parent.Parent.Text
	local playerToTradeWith
	
	if game.Players:FindFirstChild(playerText) then
		
		playerToTradeWith = game.Players:FindFirstChild(playerText)
		
		if playerToTradeWith == nil then
			
			script.Parent.Text = "That player isn't in the game!"
			script.Parent.Frame.BackgroundColor3 = Color3.fromRGB(252, 11, 35)
			script.Parent.Background.BackgroundColor3 = Color3.fromRGB(115, 12, 21)

			wait(3)
			script.Parent.Text = "Trade"

			script.Parent.Frame.BackgroundColor3 = Color3.fromRGB(36, 255, 99)
			script.Parent.Background.BackgroundColor3 = Color3.fromRGB(16, 111, 47)
			
		else
			
			game.ReplicatedStorage.RemoteEvents.TradeEvents.GetPlayerGui:FireServer(playerText)
		end
	end
end)

game.ReplicatedStorage.RemoteEvents.TradeEvents.GetPlayerGui.OnClientEvent:Connect(function(plrGui)
	
	local player = game.Players.LocalPlayer
	
	print(plrGui.Parent)
	
	if plrGui:WaitForChild("Guis").TradeGui.TradeRequest.IsBusy.Value == false then

		plrGui:WaitForChild("Guis").TradeGui.TradeRequest.IsBusy.Value = true

		plrGui:WaitForChild("Guis").TradeGui.TradeRequest.PlayerName.Text = player.Name.." wants to trade with you"
		plrGui:WaitForChild("Guis").TradeGui.TradeRequest.PlayerWantingToTrade.Value = player.Name
		plrGui:WaitForChild("Guis").TradeGui.TradeRequest.Visible = true

		script.Parent.Text = "Trade Sent"
		script.Parent.Frame = Color3.fromRGB(141, 24, 255)
		script.Parent.Background = Color3.fromRGB(62, 16, 108)
	else
		script.Parent.Text = "That player is busy right now!"
		script.Parent.Frame.BackgroundColor3 = Color3.fromRGB(252, 11, 35)
		script.Parent.Background.BackgroundColor3 = Color3.fromRGB(115, 12, 21)

		wait(3)
		script.Parent.Text = "Trade"

		script.Parent.Frame.BackgroundColor3 = Color3.fromRGB(36, 255, 99)
		script.Parent.Background.BackgroundColor3 = Color3.fromRGB(16, 111, 47)
	end
end)

5 comments

0

Is your trading system like how minecraft trading works?

0

no, like bubble gum simulator's

0

Why do you want the other players gui on the person who wants to trade?

0

oh your connect is not completed your code just says 'con'

0

nevermind i got it working. also i want the other players gui to show the changes(like if the first player in the trade adds a pet or something to the trade, itll copy on the first players ui and the second players ui)