Hello! I’m experiencing a synchronization issue and I’d like to share it.
The situation is as follows: when enabling the GUI from my proximity prompt, everything works perfectly. However, when pressing the “exitGuiButton” button in the local script, the GUI hides as expected. The issue arises when I attempt to show the GUI again using the proximity prompt; at this point, the enablement state does not update correctly.
Any suggestions or does anyone know how to resolve this problem? I would appreciate any help, as the GUI does not reappear when using the proximity prompt.
script:
local proxPrompt = script.Parent.ProximityPrompt
proxPrompt.Triggered:Connect(function(player)
print("ProximityPrompt triggered!")
local playerGui = player:FindFirstChild("PlayerGui")
if playerGui then
local rbGui = playerGui:FindFirstChild("Rebirth_UI")
if rbGui then
rbGui.Enabled = true
else
warn("Rebirth_UI not found in PlayerGui for player " .. player.Name)
end
else
warn("PlayerGui not found for player " .. player.Name)
end
end)
localscript:
local exitGuiButton = script.Parent
exitGuiButton.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local guiToHide = playerGui:WaitForChild("Rebirth_UI")
guiToHide.Enabled = false
print("Rebirth_UI has been hidden.")
end)
I’m guessing the problem arises because of a replication issue. You originally enable the gui on the server however when you press the button and the local scripts disables the gui on the client but doesn’t replicate to the server, so when you re-enable via the proximity prompt the server remains enabled anyway and doesn’t detect a change and doesn’t replicate to the client.
Thank you very much, I was able to solve it by updating the information to the server.
localscript:
local exitGuiButton = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local toggleRebirthUI = ReplicatedStorage:WaitForChild("ToggleRebirthUI")
exitGuiButton.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local guiToHide = playerGui:WaitForChild("Rebirth_UI")
guiToHide.Enabled = false
print("Rebirth_UI has been hidden.")
toggleRebirthUI:FireServer(false)
end)
server-side
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local toggleRebirthUI = ReplicatedStorage:WaitForChild("ToggleRebirthUI")
toggleRebirthUI.OnServerEvent:Connect(function(player, enabled)
local playerGui = player:FindFirstChild("PlayerGui")
if playerGui then
local rbGui = playerGui:FindFirstChild("Rebirth_UI")
if rbGui then
-- Update the GUI's enabled state
rbGui.Enabled = enabled
else
warn("Rebirth_UI not found in PlayerGui for player " .. player.Name)
end
else
warn("PlayerGui not found for player " .. player.Name)
end
end)