Gui not opening

Hi, for some reason my gui wont open.

Server Script:


event = RS:WaitForChild("MenuUI")

event.OnServerEvent:Connect(function(player, val)
	print("event fired") 
	print(val) -- prints nil
	if val == true then
		player:WaitForChild("PlayerGui"):WaitForChild("Menu"):WaitForChild("Value").Value = true
	else
		player:WaitForChild("PlayerGui"):WaitForChild("Menu"):WaitForChild("Value").Value = false
	end
	
end)```

Gui client script:

```local RS = game:GetService("ReplicatedStorage")

script.Parent:WaitForChild("Value").Changed:Connect(function(val)
	
	if val == true then
		
		script.Parent.Enabled = true
		
	else
		
		script.Parent.Enabled = false
		
	end
	
end)```

Tool Client Script:

local debounce = false
local RS = game:GetService("ReplicatedStorage")

script.Parent.Activated:Connect(function()
	print("Clicked")
	if debounce then
		print("2")
		debounce = false
		RS:WaitForChild("MenuUI"):FireServer(false)
	else
		print("1")
		debounce = true
		RS:WaitForChild("MenuUI"):FireServer(true)
	end

	
	RS:WaitForChild("MenuUI"):FireServer()
	
end)```

Are there any errors in the output?

It may be because at the end of your tool script you are firing to the server with nothing as the value, therefore changing the value to false and disabling the UI.

1 Like

ServerScripts are not supposed to handle uis (i know that by experience)
Use a localscript instead

image
After I removed this line of code everything worked.
It sends a nil value so it disables the Gui.

@sussycopper2 already said that