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

Why dont my frames turn invisible?

Oldplayer and Newplayer are 2 frames embedded in ScreenGui which is in StarterGui but this script doesnt turn either of them invisible depending on the int value of Newplayer. I feel like its something blatantly obvious

local StarterGui = game:GetService("StarterGui")
if game.StarterGui.Newplayer.Value == 1 then
	game.StarterGui.ScreenGui.Oldplayer.Visible = true
	game.StarterGui.ScreenGui.Newplayer.Visible = false
end
if game.StarterGui.Newplayer.Value == 0 then
	game.StarterGui.ScreenGui.Oldplayer.Visible = false
	game.StarterGui.ScreenGui.Newplayer.Visible = true
end

2 answers

i fixed it with some code change and shifting around some things

game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local StarterGui = game:GetService("StarterGui")
local Newplayerint = script.Newplayerint
local gui = script.Parent
while true do
	if Newplayerint.Value == 1 then -- Oldplayer
		gui.Oldplayer.Visible = true
		gui.Newplayer.Visible = false
		break
	end
	if Newplayerint.Value == 0 then -- Newplayer
		gui.Oldplayer.Visible = false
		gui.Newplayer.Visible = true
		break
	end
end

Try this:

local StarterGui = game:GetService("StarterGui")
local yes = math.clip(true, 1, false) -- true
local no = math.clip(false, 0, true) -- false
	if game.StarterGui.Newplayer.Value == 1 then
	    game.StarterGui.ScreenGui.Oldplayer.Visible = yes
	    game.StarterGui.ScreenGui.Newplayer.Visible = no
	end
	if game.StarterGui.Newplayer.Value == 0 then
	    game.StarterGui.ScreenGui.Oldplayer.Visible = no
	    game.StarterGui.ScreenGui.Newplayer.Visible = yes
	end

1 comment

0

How about starting with PlayerGui instead ;)

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