- What do you want to achieve? Keep it simple and clear!
I’m trying to make a gui frame with a textlabel saying “Go through with this action?” and two buttons: Yes/No. Every time the player tries to pick up/use an object, this will appear.
- What is the issue? Include enough details if possible!
I’m not sure what the best way to go about this is. I came up with something but it doesn’t work and I’m not sure how to fix it. (see below)
- What solutions have you thought of so far?
I’ve created this system:
Object X has a click detector and script. If a player clicks Object X, the server will make the Gui visible. It will also change the Gui text to “Pick up Object X?” If “Yes” is chosen, the object goes into the player’s backpack. If “No” then the Gui is made invisible. After wait(15) of not answering, the Gui is made invisible.
Clicking on object Object Y does the same thing. Except if you clicked “No” earlier for Object X, clicking “Yes” for Object Y will give you both objects. <<<This is the issue with my current solution.
I hope it all makes sense, because I confused myself just typing this.
Also here is the code for my broken solution:
script.Parent.MouseClick:Connect(function(plr)
local function typewriter(s)
local newstring
for i = 0, s:len(), 1 do
newstring = s:sub(1, i)
plr.PlayerGui.dialogueoption.Frame.TextLabel.Text = newstring
wait(.05)
end
end
plr.dialogueoptionGUIstatus.Value = plr.dialogueoptionGUIstatus.Value + 1 -- makes Gui visible
typewriter("A small keycard is laying in the cart. Pick it up?")
local yesbutton = plr.PlayerGui.dialogueoption.Frame.yesbutton
local nobutton = plr.PlayerGui.dialogueoption.Frame.nobutton
yesbutton.MouseButton1Up:Connect(function()
if script:GetAttribute("Done") == "yes" then
typewriter("Someone else is currently interacting with this.")
wait(3)
plr.dialogueoptionGUIstatus.Value = plr.dialogueoptionGUIstatus.Value - 1 -- makes Gui invisible
else
script:SetAttribute("Done","yes")
plr.dialogueoptionGUIstatus.Value = plr.dialogueoptionGUIstatus.Value - 1
game.ReplicatedStorage.jkeycardplayer.Value = plr.Name
game.ReplicatedStorage.JanitorKeycard:FireAllClients()
for _, Players in pairs(game.Players:GetChildren()) do
local characters = workspace[Players.Name]
if not characters:FindFirstChild("Blue Keycard") then
game.ServerStorage["Blue Keycard"]:Clone().Parent = characters
end
end
game.Workspace.JanitorKeycard:Destroy()
end
end)
nobutton.MouseButton1Up:Connect(function()
plr.dialogueoptionGUIstatus.Value = plr.dialogueoptionGUIstatus.Value - 1
end)
wait(15)
plr.dialogueoptionGUIstatus.Value = plr.dialogueoptionGUIstatus.Value - 1
end)
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I feel like it’s close to working. I just don’t know enough to fix it. I’ve tries adding connection:Disconnect() under the “No” button but it didn’t seem to change anything. Help please?