Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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)
Ad

Answer this question