Headlight script not working

I am trying to make working headlight for my tank but I am running into a weird error which I am unable to resolve.

So the error I receive is “PointLight is not a valid member of Player “Players.MaxRobuxy””

Here is my explorer window along with the location of the headlight part.
image

Here’s the script which I made,

Could anyone possibly help me find out what I am doing wrong? I’m totally clueless on this…
Thanks a lot!

3 Likes

recheck if the path for pointlightx is the right path.
where is the pointlightx supposed to be?

1 Like

What is script.Parent.Parent.Parent.Parent? Are you sure it has ‘PointLight’? Could you show more of the the Explorer hierarchy?

2 Likes

Sure and yes, It does have PointLight, In fact, it automatically fills it up when I just type it,

2 Likes

Edit: Sorry for the horrible screenshot I sent before, this one should be better.

2 Likes

you can’t use a script for the MouseButton1ClickEvent. use a localscript instead.

1 Like

Try this out:

script.Parent.Parent.Parent.Parent:WaitForChild("PointLight")
1 Like

Thanks a lot for the reply but now it gives me a different error,

2 Likes

Thanks a lot but it still gives me the same error, already tried all of these, so I had to finally resort to asking here…

2 Likes

Where is the script located? Is it local or server?

2 Likes

i think you’re missing 1 parent

script.Parent.Parent.Parent.Parent.Parent.PointLight
2 Likes

The script is located inside a meshpart called “hedlight_1”, and it is a server script, tried local but still gave me the same error.
image

1 Like

That’s some interesting behaviour. Apparently script.Parent.Parent.Parent.Parent is a player’s character? Try printing out the names of script.Parent, script.Parent.Parent, and etc.

Another annoying error which I have no clue about.
image

Wait a minute… The script is inside a GUI. Do you clone this GUI to the player? Could you also show the code for ‘HedlightController’?

1 Like

Yeah I do have to clone it so that the GUI can be visible by the player when they sit in the VehicleSeat.

1 Like

Well that means the script will be placed on the player’s PlayerGui (it won’t be in the model anymore because you moved it to the player).

1 Like

you could just access the HeadLight & pointlightx through workspace then
or put the whole code that you have in the onbutton script
into the HeadlightController.
and then delete the script.

1 Like

Thanks a billion! I finally understand my mistake, forgot that it reached the root directory of PlayerGui and not the headlight! Thanks a lot, I really appreciate the help! Now I have to figure the hard part of fixing everything ahhh.

Hey uhh sorry to bother you but how do you think I should fix this? I’m not all that sure on moving things from the GUI… So it could be a big help for me if you could help me to implement a way to move it from checking the parent of the playergui and check the parent of the meshpart…

1 Like