Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why can't I send a trade request to someone more than once?

So I'm trying to make a trading system and right now I'm working on getting the trade system to able to send a trade request to the player. I added a decline button (aka it deletes the gui) and such. Here's the script: Local script:

local remote = game.ReplicatedStorage.TradingRemotes:WaitForChild("TradeRequest")
end)
local debounce = false
local gui = script.Parent.Parent:WaitForChild("Thingy")
script.Parent.MouseButton1Down:Connect(function()
    if debounce == false then
        debounce = true
    local player2 = gui.Text --other player
    local players = game:GetService("Players")
    local player1 = players.LocalPlayer
        remote:FireServer(player2)
        wait(1)
        debounce = false
end
        end)

Server Script:

local rp = game:GetService("ReplicatedStorage")
local remote = rp.TradingRemotes:WaitForChild("TradeRequest")
remote.OnServerEvent:Connect(function(player1, player2)
    local players = game:GetService("Players")
    if players:WaitForChild(player2).PlayerGui:FindFirstChild("MoreTrade") then return end
    if player2 == player1.Name then return end
    local guifolder = game.ServerStorage:WaitForChild("TradeGuis")
    local gui = guifolder:WaitForChild("MoreTrade"):Clone()
    gui.Parent = players:WaitForChild(player2).PlayerGui
    gui.Frame.PlayerName.Text = "Incoming trade request from "..player1.Name
end)

It's supposed to not give the gui if it is in player2's playergui, but when I test, it only does it once, and not again, meaning, I send a trade request to player2, he gets the trade request but declines it, now player1 can't send a trade request to him anymore for some reason. Any help is appreciated.

1 answer

✓ Accepted answer

I think I found the problem, which is in your Server Script at line 5, which is if the "MoreTrade" gui is found in the player's PlayerGui then it should stop there, and it does after you send it once due to you never deleting the "MoreTrade" gui after finishing the trade.

So I think the solution to this problem after the trading is done is to simply add

gui:Destroy()

After inserting this I think you should be able to trade more than once with the same user

Hopefully this answers your question

2 comments

0

Thanks man I added for it to destroy it when you press the decline button and now it works!

0

Glad that it helped :)

This discussion is preserved as it was. New answers, comments, and votes are closed.