I have created a script that launches a localscript that creates a gui on the players screen, I have also attempted to create a debounce system to stop the players screen from being spammed with the same GUI, however it only allows the script to be run once, and never again. which is not what I needed, I do not know why the script does not run again after the player touches it a second time.
Have I done the debounce wrong? or is it something else?
local event = Instance.new("RemoteEvent",game.ReplicatedStorage)
event.Name = "conversation started"
local debounce = false
script.Parent.Touched:connect(function(hit)
if not debounce then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
debounce = true
event:FireClient(player,player)
end
end
end)
debounce = false

7 comments
This is unfortunately still allowing the script to spam the players screen with guis, would I be right to assume that maybe the localscript also may require a debounce system to be included?
No. I think the best bet is to create another RemoteEvent, or use the same one, and fire it from the client to the server. If you do that, I can rewrite my answer to work with that. Because as of now, the server doesn't know when the client has closed the GUI.
OOORRR better idea. In the LocalScript, simply check if the GUI exists already before you create it again.
That second one sounds simple, I shall try that! I shall update with results!
Add a wait()
No don't do that, that's terrible coding and it'll only slow down the rapid showing of GUIs
Haha no it's okay I finally got it, I have no idea why it took me so long, it went wrong quite a bit and i began to doubt myself >_< but yes I've marked this as the answer, however the answer is in the comments