Hellow fellow devforum users! When the “characters” button is pressed the surface GUI in the “options menu” part doesn’t pop up. I can’t replace the local script with a server script because then the UI will pop up for everyone instead of just the person who clicked it. All help is appreciated!
here is the hierachy
and here is the updated server script
local Event1 = script.Parent.RemoteEvent
local Event2 = script.Parent.RemoteEvent2
local OpenValue = script.Parent.Open.Value
script.Parent.MouseButton1Click:Connect(function(player)
if OpenValue == false then
Event1:FireClient(player)
OpenValue = true
else
Event2:FireClient(player)
end
end)
here is the local script that interprets the client event
local event = script.Parent.RemoteEvent
local event2 = script.Parent.RemoteEvent2
local Frame = script.Parent.Parent.Parent.Parent.OptionsMenu.SurfaceGui.Frame
event.OnClientEvent:Connect(function()
Frame.Visible = true
end)
event2.OnClientEvent:Connect(function()
Frame.Visible = false
end)
You can achieve your goal using only LocalScript without remote events and server script.
Create a LocalScript and place it either in StarterGui or in one of the other locations that @proturk_yt has specified and write the following code inside it:
local menu = workspace:WaitForChild("Menu")
local charactersBtn = menu:WaitForChild("Main"):WaitForChild("BtnUI"):WaitForChild("Characters")
local optionsMenuFrame = menu:WaitForChild("OptionsMenu"):WaitForChild("SurfaceGui"):WaitForChild("Frame")
local openValue = charactersBtn:WaitForChild("Open").Value
charactersBtn.MouseButton1Click:Connect(function()
if openValue == false then
optionsMenuFrame.Visible = true
openValue = true
else
optionsMenuFrame.Visible = false
openValue = false
end
end)
The LocalScript runs separately for each player, and players will not see how other players interact with the UI