Why don’t you just add these 2 functions in a LocalScript inside the frame itself, instead of the proximity prompt script. This should prevent the problem altogether.
i have another script that im making that needs to be server sided, i just made a simpler script because the problem already appears here in this simpler one
if there is no solution to this i could make it client sided, im just wondering if there is one as that would be better
You need to disconnect the button events after the player closes it:
local prompt = script.Parent
prompt.Triggered:Connect(function(player)
local frame = player.PlayerGui.ScreenGui.Frame
prompt.Enabled = false
frame.Visible = true
local printConn = frame.print.MouseButton1Click:Connect(function() -- set up for disconnection
print("ok")
end)
frame.close.MouseButton1Click:Once(function() -- only connects once, it disconnects automatically after 1 time
frame.Visible = false
script.Parent.Enabled = true
printConn:Disconnect() --disconnects and stops button from running until prompt is triggered again
end)
end)