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

Changing Frame's Visible Property? [Filtering Enabled]

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

3 comments

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.

0
  • The server CANNOT even see PlayerGui with FE on so it is impossible to have it do so.
0

How do I have it so that when I click it'll change the Player's Gui?

2 answers

✓ Accepted answer

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)

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)

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