Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Made a RemoteEvent where you press a button and a frame pops up [BROKE] [Any fix]?

Could someone guide me in the right direction on how to fix this so when I press the button it opens the frame or is it really unnecessary for there to be a RemoteEvent for that reason?

-- Local Script (In StarterPack)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIFrameOpenedEvent= ReplicatedStorage:WaitForChild("UIFrameOpenedEvent")
 
UIFrameOpenedEvent:FireServer()

-- Script (In ServerScriptService)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIFrameOpenedEvent = Instance.new("RemoteEvent", ReplicatedStorage)
UIFrameOpenedEvent.Name = "UIFrameOpenedEvent"

local UI = game.StarterGui.ScreenUI
local Frame = UI.ActualFrame 
local Profile = UI.Profile

local function onUIOpenedFired(player)
	UI.Profile.MouseButton1Click:Connect(function(player)
		Frame.Visible = not Frame.Visible
	end)
end
 
UIFrameOpenedEvent.OnServerEvent:Connect(onUIOpenedFired)

1 answer

✓ Accepted answer

You don't need to have a Script in the ServerScriptService to make local interfaces visible. This can just be put in a LocalScript:

--Assume that the LocalScript has the same parent as the button

local Frame = [THE FRAME TO BE OPENED. EX : script.Parent:WaitForChild'Frame']

local function OpenInterface()
	Frame.Visible = not Frame.Visible
end

script.Parent:WaitForChild'NAMEOFTHEBUTTON'.MouseButton1Down:Connect(OpenInterface)

This discussion is preserved as it was. New answers, comments, and votes are closed.