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

[SOLVED] GUI isn't appearing although changing in test mode in ROBLOX Studio. What did I do wrong?

Asked by 5 years ago
Edited 4 years ago

Apologies if this is a stupid question, I'm new to Lua coding, however when I touch my brick, the background transparency VALUE changes as it should, however the GUI does not appear, despite when looking at the value in testing being gradually changed to 0. Apologies also if the code is a bit messy.

function onTouched(player) --Enables when brick is touched.
    local parent = player.Parent
    local stageGui = game.StarterGui.Stage
    if game.Players:GetPlayerFromCharacter(parent) then --Makes sure a player touched it.
        if game.Players[player.Parent.Name].leaderstats.Stage.Value == 0 then --Checks if Stage (leaderstat value) is 0.
            stageGui.Welcome.BackgroundTransparency = 0.9 --Gradually Changes the Transparency of the GUI.
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.7
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.5
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.3
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0
            wait(4)
            stageGui.Welcome.BackgroundTransparency = 1 --After 4 seconds make the GUI invisible.
        end
    end
end


script.Parent.Touched:connect(onTouched)

Nothing appears in the output.

0
This is where remote functions and events come into play, take a look at this resource: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events ForeverBrown 356 — 5y
0
I do not know if this is true or not, but it may be because you listed "parent" meaning that the game might become confused and stop working. hoth7 45 — 5y
0
change local stageGui = game.StarterGui.Stage to player.PlayerGui.Stage Gameplayer365247v2 1055 — 5y
0
parent is a code part, it jumps out of the script to whatever the script is in, the more parents, the higher up the explorer it goes in the >< open areas, like frame > script, script.Parent.Parent means it would go to the frame, script.Parent = text button RobloxGameingStudios 145 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Turns out it was because I was calling on the GUI stored in StarterGui, instead of the one stored in the player. Just going to post this here as it worked!

function onTouched(player) --Enables when brick is touched.
    local parent = player.Parent
    local stageGui = game.Players[player.Parent.Name].PlayerGui.Stage --Calls on the PLAYERS Gui.
    if game.Players:GetPlayerFromCharacter(parent) then --Checks a player touched it.
        if game.Players[player.Parent.Name].leaderstats.Stage.Value == 0 then --Checks if Stage is 0.
            stageGui.Welcome.BackgroundTransparency = 0.9 --Gradually makes GUI visible.
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.8
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.7
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.6
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.5
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.4
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.3
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.2
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0.1
            wait(0.1)
            stageGui.Welcome.BackgroundTransparency = 0
            wait(4) --After 4 seconds makes GUI invisible.
            stageGui.Welcome.BackgroundTransparency = 1
        end
    end
end

script.Parent.Touched:connect(onTouched)
0
wha? Is that a local script/part? ForeverBrown 356 — 5y
0
It's a normal script stored in a part and calls on the script when it is touched. LegacyBraxd 5 — 5y
0
but you cant change the client from the server....lol i'm confused. ForeverBrown 356 — 5y
0
OH I meant in StarterGui not the server lmao LegacyBraxd 5 — 5y
Ad

Answer this question