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

Changing Frame's Visible Property? [Filtering Enabled]

Asked by 6 years ago

I honestly don't understand why it actually stopped working, it was working yesterday on my laptop. I did have FilteringEnabled on too. Basically, if I click a button, it should turn off visibility for the first frame, and turn on visibility for the second frame.

Server Script

local RepStorage = game:GetService("ReplicatedStorage")
local Function = RepStorage:WaitForChild("PlayEvent")

wait(0.5)

local StarterGui = game:GetService("StarterGui")
local startgame = StarterGui:WaitForChild("StartGame")
local frame = startgame:WaitForChild("Frame")
local button = frame:WaitForChild("Play")

local function ChangeGui(player)
    print(player.Name, "wants to change GUI.")
    Function:FireClient(player)
end

button.MouseButton1Click:Connect(ChangeGui)

LocalScript

wait(0.5)

local RepStorage = game:GetService("ReplicatedStorage")
local Function = RepStorage:WaitForChild("PlayEvent")

local player = game.Players.LocalPlayer
local playergui = player:WaitForChild("PlayerGui")
local startgame = playergui:WaitForChild("StartGame")
local frame = startgame:WaitForChild("Frame")
local button = frame:WaitForChild("Play")
local playframe = startgame:WaitForChild("PlayFrame")

local function ChangeGui()
    if frame.Visible == true then -- if first frame visible
        frame.Visible = false -- visible off
        playframe.Visible = true -- other frame visible on
    else
        frame.Visible = true
        playframe.Visible = false
    end
end

Function.OnClientEvent:Connect(ChangeGui)

Could it be that I'm using "Function" as a variable, or could it be that ROBLOX has trouble getting RemoveEvents across? I really don't know, I'm new to FE lol.

Thanks,

LukeGabrieI

0
no one can click the button in starterGui. there's no need to have a server sided script involved in UI. UI's are supposed to be client-only in the first place. RubenKan 3615 — 6y
0
+ The server CANNOT even see PlayerGui with FE on so it is impossible to have it do so. lukeb50 631 — 6y
0
How do I have it so that when I click it'll change the Player's Gui? LukeGabrieI 73 — 6y

2 answers

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago

Local script:

local player = game.Players.LocalPlayer
local playergui = player:WaitForChild("PlayerGui")
local startgame = playergui:WaitForChild("StartGame")
local frame = startgame:WaitForChild("Frame")
local button = frame:WaitForChild("Play")
local playframe = startgame:WaitForChild("PlayFrame")

-- If playframe's parent is frame, and you set frame's visible to false, then both of them will not show.

function SET_VISIBILITY()
    if (frame.Visible == true) and (not playframe.Visible) then 
        frame.Visible = false 
        playframe.Visible = true 

    elseif (not frame.Visible) and (playframe.Visible == true) then 
        frame.Visible = true 
        playframe.Visible = false 
    end
end

button.MouseButton1Click:connect(SET_VISIBILITY)
Ad
Log in to vote
0
Answered by 6 years ago

LocalScript inside the TextButton:

function onClick() -- No passable parameters.
    frame.Visible = not frame.Visible -- changed the current Visible state of the frame to its opposite. so if true then false if false then true.

end

script.Parent.MouseButton1Click:Connect(onClick)

Answer this question