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")
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
end
end
local services = setmetatable({},{
__index = function(self,ind)
if ypcall(function() game:GetService(ind) end) then
return game:GetService(ind)
else
return nil
end
end
})
services.Workspace
local Services = {}
local Mt = {}
function Mt:__index(k)
local Service = rawget(self, k)
if not Service then
xpcall(function()
Service = game:GetService(k)
end, function()
error(`Services: '{k}' is not an known service`, 3)
end)
rawset(self, k, Service)
end
return Service
end
function Mt:__newindex(k,v)
return error(`Services: Attempt to assign value '{v}' to key '{k}'. Key is read-only`, 2)
end
setmetatable(Services, Mt)
--
local ReplicatedStorage = Services.ReplicatedStorage
-- Ok!
local AnyService = Services.AnyService
-- Not ok!
-- 'AnyService' is not an known service.
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.