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

Why dont my frames turn invisible?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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
Ad
Log in to vote
-1
Answered by 4 years ago

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
0
How about starting with PlayerGui instead ;) Ziffixture 6913 — 4y

Answer this question