GUI does not enable repetitively

I have a simple script written. Its purpose is not relevant beyond the point that, when a proximity prompt is triggered, the BuildingGui below should enable.
The issue here is that the script works just fine the first time it’s used, but the second time the GUI fails to enable (it has been disabled by another script in the interim). Despite returning that it is enabled, a quick look at the explorer proves otherwise and the GUI functions perfectly fine once I manually enable it again through the explorer.

local Prompt = script.Parent.PlatePrompt
local Storage = game:GetService("ReplicatedStorage")
local PlateInUse = Storage.PlateInUse

Prompt.Triggered:Connect(function(player)
	Prompt.Enabled = false
	
	if player.PlayerGui.BuildingGui.Enabled == false then
		player.PlayerGui.BuildingGui.Enabled = true
	end
	if player.PlayerGui.BuildingGui.Enabled == true then
		print("GUI enabled.")
	end
	
	PlateInUse.Value = script.Parent.CFrame
end)

Any ideas would be very much appreciated.
I’m sure I’m just missing something very obvious but I can’t for the life of me figure out what it is.

Is this ever set back to true …

No, but the script is replicated across multiple different locations with different proximity prompts. The prompts in the other locations still work, and I’ve tested not disabling the prompt anyway, to no avail.

The problem is the server sees the GUI as Enabled.

When you set the GUI enabled property with a local script (I assume that’s what you are doing), the GUI is disabled locally.

(A local script)
Client sees it as:
Enabled = false

(Proximity Prompt)
Server sees it as:
Enabled = true

To the server it’s already true so it doesn’t change anything.

1 Like

If you ultimately need the GUI to be visible, you could do this:

Prompt.Triggered:Connect(function(player)
	Prompt.Enabled = false

	player.PlayerGui.BuildingGui.Enabled = false
	player.PlayerGui.BuildingGui.Enabled = true
	
	PlateInUse.Value = script.Parent.CFrame
end)

If the server has control over a player’s GUI, you need to do these manipulations to ensure the desired effect.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.