Hello, im trying to make a system to locally change transparency of a part in a vehicle using a button in the gui for the driver.
While scripting it using script.Parent.Parent.Parent.Parent.Parent.Body.Frontback.Transparency=0.5 output says this:
It doesn’t make sense since while writing the script body shows up after last parent:
I tried using workspace.ManCoach.Body.Frontback.Transparency=0.5 but it doesn’t work because spawning system of the game is clone a vehicle from serverstorage and move it to workspace and if there is more than a vehicle spawned at same time it changes transparency of only first one (even if you click while you are in second).
This is the script, only 2 first lines are the important of this post: script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.Parent.Parent.Parent.Body.Frontback.Transparency=0.5 script.Parent.Parent.DisableFrontBack.Visible=true script.Parent.Visible=false end)
Im trying to change transparency of a workspace part, but for some reason output shows that error that doesn’t match with my script, here is a video of what I’m trying to do but doesn’t work with more than 1 vehicle at same time in the game
That code printed where the script is running.
Players.iagocity2005.PlayerGui[“Chassis Interface”].ScreenGui.EnableFrontBack.LocalScript.
The issue is coming from this line:
script.Parent.Parent.Parent.Parent.Parent.Body.Frontback.Transparency=0.5
If we follow that up the hierarchy we get
Script = LocalScript
Parent1 = EnableFrontBack
Parent2 = ScreenGui
Parent3 = Chassis Interface
Parent4 = PlayerGui
Parent5 = iagocity2005
There is where you stop rising in the game tree and start moving back down. The issue is that you are searching for Body of the car under the location ‘game.Players.iagocity2005’ which is a player object causing you to get that error. You are going to have to grab it through a more absolute method in order to get it, like calling it from workspace.
With your earlier attempt only changing a single car, it’s due to the fact that they share the same fullName so roblox only returns the first one. To fix that you will need to find a way to either name them differently or send the information on which vehicle through another way. I don’t know enough about how your gui gets sent to the playerGui, but if I had to guess I’d say it’s from when a player sits in the driver seat. If that’s the case you could fix the issue by sending the variable information of the vehicle along with the scripts and stuff. (Like sticking an object value in the screen gui for the other script to read or using remote events)