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

This gui is still invisible after click?

My gui doesn't go to visible after i set it to true any help? LFrame is the frame there are no errors in the output (that may be because its studio) but i've tried it in real game and it still doesnt work

this is the Load button clicked:

function loadScore(plyr, clickCounter)

	local score = plyr:LoadNumber("Stage") 

	if not score == 0 then
		clickCounter.Value = score
	else
		print("Nothing to load../..score was 0")
	end

end



function onClicked(Player)

    local player = script.Parent.Parent.Parent.Parent.Parent
        player:WaitForDataReady()
if player.DataReady == true then
        loadScore(player, player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value))
        player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value).Value = player:LoadNumber("Stage")
local m = player.PlayerGui.Loading.LFrame
m.Visible = true

            player.Character.Humanoid.Health = 0
        wait(3)
        m.Visible = false
    else
    local mes = Instance.new("Message",player.PlayerGui)
    mes.Text = "Wait until DataReady!"
        game:service("Debris"):AddItem(mes, 3)
    end
end 

script.Parent.MouseButton1Click:connect(onClicked)

and this is the save button clicked:

function loadScore(plyr, clickCounter)

	local score = plyr:LoadNumber("Stage") 

	if not score == 0 then
		clickCounter.Value = score
	else
		print("Nothing to load../..score was 0")
	end

end



function onClicked(Player)

    local player = script.Parent.Parent.Parent.Parent.Parent
        player:WaitForDataReady()
if player.DataReady == true then
        loadScore(player, player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value))
        player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value).Value = player:LoadNumber("Stage")
local m = player.PlayerGui.Saving.SFrame
m.Visible = true

            player.Character.Humanoid.Health = 0
        wait(3)
        m.Visible = false
    else
    local mes = Instance.new("Message",player.PlayerGui)
    mes.Text = "Wait until DataReady!"
        game:service("Debris"):AddItem(mes, 3)
    end
end 

script.Parent.MouseButton1Click:connect(onClicked)

1 answer

Few things to note: player is a variable you create but then you never use it again in your script. you can save SO much time by using player instead of script.Parent.Parent.Parent.Parent.Parent every single time you want to access the player.

As for the real problem with your code:

the line m = game.StarterGui.Loading.LFrame looks for the Gui in StarterGui, which is a server item, NOT the actual Gui that players see. The Gui you want to look for is PlayerGui, which you can find by using player.PlayerGui

This code should work now

function onClicked(Player)

    player = script.Parent.Parent.Parent.Parent.Parent
        player:WaitForDataReady()
if player.DataReady == true then
        loadScore(player, player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value))
        player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value).Value = player:LoadNumber("Stage")
local m = player.PlayerGui.Loading.LFrame
m.Visible = true

            player.Character.Humanoid.Health = 0
        wait(3)
        m.Visible = false
    else
    local mes = Instance.new("Message",player.PlayerGui)
    mes.Text = "Wait until DataReady!"
        game:service("Debris"):AddItem(mes, 3)
    end
end 

script.Parent.MouseButton1Click:connect(onClicked)

1 comment

0

it still didn't work... i'll post my full code real quick

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