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

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

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.

4 comments

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

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.

0

change local stageGui = game.StarterGui.Stage to player.PlayerGui.Stage

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

1 answer

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)

4 comments

0

wha? Is that a local script/part?

0

It's a normal script stored in a part and calls on the script when it is touched.

0

but you cant change the client from the server....lol i'm confused.

0

OH I meant in StarterGui not the server lmao

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