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)