Issue with my own trade system

I’m making my own trade system, but every time I have an annoying problem: the gui appears only for the player who sent the trade.

how i can fix this?

server script:

game.ReplicatedStorage.Trade.OnServerEvent:Connect(function(plr, an)
	game.Players[an.Name].PlayerGui["Menu Gui"].Notify:Play()
	game.Players[an.Name].PlayerGui["Menu Gui"].Req.Visible = true
	game.Players[an.Name].PlayerGui["Menu Gui"].Req.nam.Text = "New trade request from: @" .. plr.Name
	game.Players[an.Name].PlayerGui["Menu Gui"].Req.TradeTo.Value = an.Name
	wait(15)
	game.Players[an.Name].PlayerGui["Menu Gui"].Req.Visible = false
end)

game.ReplicatedStorage.Trade.Decline.OnServerEvent:Connect(function(plr, an)
	game.Players[plr.Name].PlayerGui["Menu Gui"].Req.Visible = false
	game.ReplicatedStorage.Trade.Decline:FireClient(game.Players[plr.Name])
	game.ReplicatedStorage.Trade.Decline:FireClient(game.Players[an.Value])
	
	game.Players[an.Name].PlayerGui["Menu Gui"].Trade.Trade.man.Text = "TRADE REQUEST DECLINED!"
	game.Players[an.Name].PlayerGui["Menu Gui"].Decline:Play()
	wait(3)
	game.Players[an.Name].PlayerGui["Menu Gui"].Trade.Trade.man.Text = "???"
end)

game.ReplicatedStorage.Trade.Accept.OnServerEvent:Connect(function(plr, an)
	local backer = game.Players:WaitForChild(an.Value)
	game.Players[plr.Name].PlayerGui["Menu Gui"].Req.Visible = false
	game.ReplicatedStorage.Trade.Accept:FireClient(game.Players[an.Value])
	--game.ReplicatedStorage.Trade.Accept:FireClient(backer)
	--game.ReplicatedStorage.Trade.Accept:FireClient(plr)
	
	game.Players[plr.Name].PlayerGui["Menu Gui"].Accept:Play()
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Players.ScrollingFrame.Visible =false
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Trade.trade.Visible =false
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Trade.TextButton.Visible =false
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Trade.CHOOSE.Visible =false
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Players.Offers.Visible = true
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Trade.Offers.Visible = true
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Trade.man.Visible =false
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.CHOOSE.Visible = true
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.CHOOSE.Text = "V    V    V"
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Trade.tip.Text = "⚠️ CHOOSE SOMETHING TO OFFER ⚠️"
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Buttons.Visible = true
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.TextButton.Visible = false
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Accept.Visible = true
	game.Players[plr.Name].PlayerGui["Menu Gui"].Frame.Trade.Decline.Visible = true
end)

game.ReplicatedStorage.Trade.Otmena.OnServerEvent:Connect(function(plr, an)
	game.ReplicatedStorage.Trade.Otmena:FireClient(game.Players[an])
end)

local script:

local can = false
local plr
local deb = false
local declined = false

game["Run Service"].RenderStepped:Connect(function()
	for _, player in pairs(game.Players:GetPlayers()) do
	if not script.Parent:FindFirstChild(player.Name) and player.Name ~= game.Players.LocalPlayer.Name then
	local add = script.Primer:Clone()
	add.Name = player.Name
	add.Parent = script.Parent
	add.BB.Text = "@"..player.Name
	add.TextButton.Activated:Connect(function()
		if player.CoinStats.Can.Value ~= 0 and deb == false then
		script.Parent.Parent.Parent.Trade.man.Text = "@"..player.Name
		script.Parent.Parent.Parent.Trade.trade.BackgroundColor3 = Color3.new(0.333333, 1, 0)
		script.Parent.Parent.Parent.Players.ScrollingFrame[player.Name].BackgroundColor3 = Color3.new(0.333333, 1, 0)
		for _, anth in pairs(script.Parent.Parent.Parent.Players.ScrollingFrame:GetChildren()) do
			if anth.Name ~= player.Name and anth:IsA("Frame") then
				anth.BackgroundColor3 = Color3.new(0.568627, 0.568627, 0.568627)
			end
		end
		can = true
		plr = player
		end
	end)
	end
  end
end)

game.Players.PlayerRemoving:Connect(function(p)
	if script.Parent:FindFirstChild(p.Name) then
		script.Parent[p.Name]:Destroy()
	end
	if plr ~= nil then
		if plr.Name == p.Name then
			plr = nil
			can = false
		end
	end
end)

script.Parent.Parent.Parent.Trade.trade.Activated:Connect(function()
	if can == true and deb == false then
		game.ReplicatedStorage.Trade:FireServer(plr)
		script.Parent.Parent.Parent.Trade.trade.BackgroundColor3 = Color3.new(0.666667, 0, 0)
		script.Parent.Parent.Parent.Players.ScrollingFrame[plr.Name].BackgroundColor3 = Color3.new(0.568627, 0.568627, 0.568627)
		deb = true
		can = false
		script.Parent.Parent.Parent.Trade.man.Text = "TRADE SENT!"
		wait(3)
		if deb == true and declined == false then
		script.Parent.Parent.Parent.Trade.man.Text = "???"
		plr = nil
		deb = false
		end
		declined = false
	end
end)

game.ReplicatedStorage.Trade.Decline.OnClientEvent:Connect(function(r)
script.Parent.Parent.Parent.Trade.man.Text = "TRADE REQUEST DECLINED!"
	script.Parent.Parent.Parent.Parent.Parent.Decline:Play()
	deb = true
	wait(3)
	script.Parent.Parent.Parent.Trade.man.Text = "???"
	plr = nil
	deb = false
end)

game.ReplicatedStorage.Trade.Accept.OnClientEvent:Connect(function()
	print("kwkdkfefefefeegrtger")
	script.Parent.Parent.Parent.Parent.Parent.Accept:Play()
	script.Parent.Parent.Parent.Players.ScrollingFrame.Visible =false
	script.Parent.Parent.Parent.Trade.trade.Visible =false
	script.Parent.Parent.Parent.Trade.TextButton.Visible =false
	script.Parent.Parent.Parent.Trade.CHOOSE.Visible =false
	script.Parent.Parent.Offers.Visible = true
	script.Parent.Parent.Parent.Trade.Offers.Visible = true
	script.Parent.Parent.Parent.Trade.man.Visible =false
	script.Parent.Parent.Parent.CHOOSE.Text = "V    V    V"
	script.Parent.Parent.Parent.Trade.tip.Text = "⚠️ CHOOSE SOMETHING TO OFFER ⚠️"
	script.Parent.Parent.Parent.Parent.Buttons.Visible = false
	script.Parent.Parent.Parent.Parent.TextButton.Visible = false
end)

script.Parent.Parent.Parent.Decline.Activated:Connect(function()
	game.ReplicatedStorage.Trade.Otmena:FireServer(plr)
	
	script.Parent.Parent.Parent.Parent.Parent.Decline:Play()
	script.Parent.Parent.Parent.Players.ScrollingFrame.Visible =true
	script.Parent.Parent.Parent.Trade.trade.Visible =true
	script.Parent.Parent.Parent.Trade.TextButton.Visible =true
	script.Parent.Parent.Parent.Trade.CHOOSE.Visible =true
	script.Parent.Parent.Offers.Visible = false
	script.Parent.Parent.Parent.Trade.Offers.Visible = false
	script.Parent.Parent.Parent.Trade.man.Visible =true
	script.Parent.Parent.Parent.CHOOSE.Text = "SELECT A PLAYER TO START TRADE"
	script.Parent.Parent.Parent.Trade.tip.Text = "PLAYERS"
	script.Parent.Parent.Parent.Parent.Buttons.Visible = true
	script.Parent.Parent.Parent.Parent.TextButton.Visible = false
end)

game.ReplicatedStorage.Trade.Otmena.OnClientEvent:Connect(function()
	script.Parent.Parent.Parent.Trade.man.Text = "TRADE DECLINED!"
	script.Parent.Parent.Parent.Parent.Parent.Decline:Play()
	script.Parent.Parent.Parent.Players.ScrollingFrame.Visible =true
	script.Parent.Parent.Parent.Trade.trade.Visible =true
	script.Parent.Parent.Parent.Trade.TextButton.Visible =true
	script.Parent.Parent.Parent.Trade.CHOOSE.Visible =true
	script.Parent.Parent.Offers.Visible = false
	script.Parent.Parent.Parent.Trade.Offers.Visible = false
	script.Parent.Parent.Parent.Trade.man.Visible =true
	script.Parent.Parent.Parent.CHOOSE.Text = "SELECT A PLAYER TO START TRADE"
	script.Parent.Parent.Parent.Trade.tip.Text = "PLAYERS"
	script.Parent.Parent.Parent.Parent.Buttons.Visible = true
	script.Parent.Parent.Parent.Parent.TextButton.Visible = false
	deb = true
	declined = true
	wait(3)
	script.Parent.Parent.Parent.Trade.man.Text = "???"
	deb = false
end)
1 Like

kergkergergreekgpokeprgkergokedidfg
Please MAKE VARIABLES for GUIS!!! MAKE VARIABLES!!!
MY EYES ARE BURNING!!

SCRIPT.PARENT.PARENT.PARENT

2 Likes

for me this is the easiest way xd

1 Like

I’m not going to help you until you’ll make variables. And nobody will.
Why this is “easiest”? Just make

local PlayerGui = path.to.player.gui

and everything will be really easier.

3 Likes

i know, but the main thing for me is to know why the remote event does not work, there are no errors in the code

On the server event that listens to when Trade.Accept gets fired, it never actually makes the trade UI for the player you are trading with appear. The LocalScript never fires the event either, unless it’s in a separate script,

Also I agree, use variables for your UI!

yes, it is never not displayed only for 1 player, namely the one who sent the trade request

Can you explain what an is. Is it the player itself or a value?

plr - the player who accepts the trade, an - the player who fired the event (requesting trade)

You could try replacing an.Value with an.Name in this case here.

and an.Value with just an here.

Player instances do not have a property named Value, so not entirely sure why you did that.

an it’s a “IntValue” with the number that is the player’s name

IntValues can only store numbers though, not strings or names.

ahh, then what should I use instead?

Please, for the love of god, use variables to make your code readability better. I seriously can’t help with this type of code format.

1 Like

In this case, you should use a StringValue.

or an ObjectValue if you wanna directly reference the player.

ok, I’ll try it now and tell you if it helped

hm, doesn’t work, same problem :frowning:

Hey man, I really want to help you, but it would be way way way easier if you can just make variables for your code, because not only it helps with readability but it also helps us to track down the root cause easier.

maybe I’m using events incorrectly or something?

okay, it just takes me 10 minutes to rewrite the code again xd

1 Like