Still have questions? Join our Discord server and get real time help.
0

# I'm trying to make a trade system but I can't seem to get the PlayerGui?

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

realPlayer = possiblePlayer
break
end
end

local playerGui = realPlayer:FindFirstChild("PlayerGui")

end)


Client script:

script.Parent.MouseButton1Down:Connect(function()

local player = game.Players.LocalPlayer
local playerText = script.Parent.Parent.Text

if game.Players:FindFirstChild(playerText) 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.Frame.BackgroundColor3 = Color3.fromRGB(36, 255, 99)
script.Parent.Background.BackgroundColor3 = Color3.fromRGB(16, 111, 47)

else

end
end
end)

local player = game.Players.LocalPlayer

print(plrGui.Parent)

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.Frame.BackgroundColor3 = Color3.fromRGB(36, 255, 99)
script.Parent.Background.BackgroundColor3 = Color3.fromRGB(16, 111, 47)
end
end)

0