Problems when using Script.Parent on "Local"

Hello I’m WikiHermanic and I’m currently trying to make an Aircraft Landing Gear System by firing a Remote Event to make a Part Invisible.

The issue that I’m having seems to be using Script.Parent on the first Local. I tried to come up with more scripts but it just doesn’t work. Here is an example:

Local aircraft = Script.Parent.Parent.Aircraft

However, it works when I used “Workspace”, but it made the Aircraft specific names only or doesn’t work when the name is the same since I’m making it use a Vehicle Spawner. Here is the script:

Local aircraft = Workspace:FindFirstChild("Aircraft")
1 Like

I don’t understand about the first one. But the second one if you don’t want specific names. Try this I guess

local Child = workspace:GetChildren()

for i,aircrafts in pairs(Child) do
if aircrafts.Name == "Aircraft" and aircrafts:IsA("Model") then -- Your aircraft might would be a model.
-- your goofy ahh code or idk
1 Like

This is probably the issue, it needs to be script instead(all lowercase).

also Local should be lowercase as well(local). Same goes for Workspace it needs to be either workspace or game.Workspace.

yep that is it i can confirm u nyrion

Hello! I have found a couple of errors that can result in your code not working. Try these and tell me what happens.

Change “Local” and “Script” to lowercase letters.

Change “Local” and “Workspace” to lowercase letters.

And just to try, change:

to this:

local aircraft = game.workspace:WaitForChild("Aircraft")

Hope this helps! :slight_smile:

1 Like

This is false, it needs to be game.Workspace or workspace, or if you’re insane game:GetService("Workspace").

1 Like

‘Local’ should be in lowercase.
‘Script’ too.

local aircraft = script.Parent:FindFirstChild("Aircraft")

Or if you’re really insane:

local services = setmetatable({},{
    __index = function(self,ind)
        if ypcall(function() game:GetService(ind) end) then
            return game:GetService(ind)
            return nil


Or if you’re really really insane:

local Services = {}
local Mt = {}

function Mt:__index(k)
     local Service = rawget(self, k)

     if not Service then
               Service = game:GetService(k)
          end, function()
               error(`Services: '{k}' is not an known service`, 3)
          rawset(self, k, Service)

     return Service

function Mt:__newindex(k,v)
    return error(`Services: Attempt to assign value '{v}' to key '{k}'. Key is read-only`, 2)

setmetatable(Services, Mt)
local ReplicatedStorage = Services.ReplicatedStorage
-- Ok!

local AnyService = Services.AnyService
-- Not ok!
-- 'AnyService' is not an known service.

stack overflow because it keeps calling __index :skull:

1 Like

If you know right where the script is and where the part is you’re looking for these should work.
Local aircraft = Script.Parent.Parent.Aircraft or Local aircraft = Workspace:FindFirstChild(“Aircraft”)

Should be able to type it out in the Studio stopping at the . and it should show options of what’s there or within the " " for FindFirstChild.

However if you loading, swapping parts around or cloning - then calling this, try …
Local aircraft = Workspace:WaitForChild(“Aircraft”)

Never had a problem with .Parent are you sure you’re aiming at the right place.

I’m trying to make it duplicatable so it’s not supposed to be specific

I also tried lowercase letters but it still won’t function

You could try using “:WaitForChild()”

edit: realized someone already suggested that.

I did it 2 days ago but still no luck

It still have the same issue sadly

Here is the script i used:

local tool = script.Parent
local GearEvent = tool.GearEvent

local aircraft = script.Parent.Parent.Parent.Parent.Parent.Parent.Aircraft
local gear1 = aircraft.TestVehicle.Gear.LandingGear1
local gear2 = aircraft.TestVehicle.Gear.LandingGear2
local gear3 = aircraft.TestVehicle.Gear.LandingGear3

	if connection == "UP" then
		gear1.Transparency = 1
		gear1.CanCollide = false
		warn("Set Gear - UP")
	elseif connection == "DOWN" then
		gear1.Transparency = 0
		gear1.CanCollide = true
		warn("Set Gear - DOWN")

	if connection == "UP" then
		gear2.Transparency = 1
		gear2.CanCollide = false
		warn("Set Gear - UP")
	elseif connection == "DOWN" then
		gear2.Transparency = 0
		gear2.CanCollide = true
		warn("Set Gear - DOWN")

	if connection == "UP" then
		gear3.Transparency = 1
		gear3.CanCollide = false
		warn("Set Gear - UP")
	elseif connection == "DOWN" then
		gear3.Transparency = 0
		gear3.CanCollide = true
		warn("Set Gear - DOWN")

could you show your instance hierarchy?

What is an instance hierarchy?

Are you sure it isn’t shorter to go from the workspace… ( just a guess here )

local aircraft = workspace:WaitForChild(“vehicles”)