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.
That is because the server cannot access the client, and the client cannot access the server. To fix this, you'd need to use a RemoteEvent.
More about RemoveEvents: https://www.robloxdev.com/api-reference/class/RemoteEvent
Hope this helped you.