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

Not a valid member of PlayerGui?

This is the script

local followMouse = script.Parent.Parent.FollowMouseScript

followMouse.Disabled = false

I checked a bunch of times, it is a member of PlayerGui!!! But it just keeps giving me this error saying FollowMouseScript is not a valid member of PlayerGui, is this a bug or is it really just me!?

The script above is a Script inside a Gui inside StarterGui, and I made it to activate a LocalScript that is inside StarterGui.

I tested this 10 times or more, and it keeps bringing me the same error!

2 answers

✓ Accepted answer

Try using :

local followMouse = script.Parent.Parent:WaitForChild('FollowMouseScript')

followMouse.Disabled = false

The only difference is that you're waiting for it to exist. Because the script might be trying to define it when the followmousescript hasn't been loaded yet.

3 comments

0

exactly. had similar problem when making a train driving script and it required certain values, and it was randomly throwing an error.

0

Oh mehhh guud, Thank u so much it's a masterpiece now becuz of u!! :D

0

no problem :)

If your game is FE, scripts cannot access the descendants of PlayerGui. Try doing something other than that

5 comments

0

Thing is, it's not FE. :p

0

well, then you're probably not waiting for the gui instances to load, because everything doesn't load in immediately as you join the game. Use WaitForChild()

0

they CAN access but if a player script modifies something in PlayerGui then the server and other players wont see changes to it and may break some scripts.

0

A server - sided script(Normal script) can access the PlayerGui instance, but not its descendants when FE is enabled. He's not dealing with FE

0

Well, thanks for the extra information and for the answer too.

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