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

ClickDetector Script that Changes GUI no Longer Works?

So, I want to have a feature in my game where certain objects can be clicked to show some flavor text on the player's screen. I decided to go about this by putting a ScreenGui with a TextLabel in it in Player.Gui. I put a ClickDetector and a script in a model so that when the model is clicked, the TextLabel will be activated and fadeout, deactivating afterwards. To prevent bugs, the ClickDetector is only usable when the TextLabel is deactivated. Here's my script:

local click = script.Parent.ClickDetector
local msg = "A bit late to go outside..."

click.MouseClick:Connect(function(plr)
	local text = plr.PlayerGui.ScreenGui.TextLabel
	if text.Active then
	else
		text.Active = true
		text.Text = msg
		text.TextTransparency = 1
		for a=1,0,-.01 do
			text.TextTransparency = a
		end
		text.Active = false
	end
end)

However, when I click the model, it spits out an error at me.

'ScreenGui is not a valid member of PlayerGui'

It seems like, for some odd reason, it doesn't think ScreenGui exists??? I've used this method before and it worked fine, so there must have been some update that broke it.

3 comments

0

Then it's because there is no child called ScreenGui inside PlayerGui. Keep in mind StarterGui is cloned locally the guis created only exist on the client and not the server.

0

Oh, thanks, I didn't know it was local (Although I don't think it was always like that). How might I go about accessing it with a ClickDetector, then?

0

Use a RemoteEvent and :FireClient

1 answer

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