I meant about the Script.Parent. It can’t Function
This is a tool? … you’re adding to the backpack. That changes everything.
Figure out where this is from the workspace and locate it that way from the tool GearScript.
If this is the case …
@WikiHermanic
Back i just screenshotted and yeah it’s a tool
The tool is inside the Pilots Seat
When you put that tool on … equipped it … that changed where the script itself is.
( I think ) … play this out and look where the script is located in the hierarchy while it’s running.
Wait so… when I equip the tool it changes the location of the Script?
Oh yep!!!
You need to key off the workspace here. not parent. Show us the hierarchy from workspace.
Hierarchy is Explorer right? And here:
local aircraft = workspace:WaitForChild(“Aircraft”)
Yeah that’s what i did, but it made the Aircraft unduplicatable
Now you’re duplicating it? Make the duplicate Aircraft2 … idk, not getting all the information here.
Well that will work for one aircraft but if you wanted to use multiple aircraft it will not work.
You should use an object value triggered by the seat
put this script inside a seat
-- Create a seat object and name it "Seat"
local Seat = Instance.new ("Seat")--you already have a seat
Seat.Name = "Seat"
Seat.Parent = workspace
local airc = Instance.new ("ObjectValue")--do this manually please
airc.Name = "airplane"
airc.Parent = Seat["Aircraft Control"]
airc.Value=script.Parent.Parent.Parent--make it the parent so you can use multiple craft
-- Create a function that runs when the seat's occupant property changes
local function onOccupantChanged ()
-- Get the humanoid that is sitting in the seat
local Humanoid = Seat.Occupant
-- If there is a humanoid, then a player has touched the seat and is seated to it
if Humanoid then
-- Get the player from the humanoid's parent
local Player = game.Players:GetPlayerFromCharacter (Humanoid.Parent)
if Player then
tool=Seat["Aircraft Control"]:Clone()
tool.Parent=Player.Backpack
wait()
Player.Character.Humanoid:EquipTool(tool)
local unseat=Player.Character.HumanoidHumanoid.Running:connect(function() tool:Destroy() unseat:Disconnect() end)
unseat:Connect()
end
-- Print a message to the output
print (Player.Name .. " has touched the seat and is seated to it")
end
end
-- Connect the function to the seat's occupant changed event
Seat:GetPropertyChangedSignal ("Occupant"):Connect (onOccupantChanged)
Oh… I was trying to make the Aircraft use a Vehicle Spawner
This looks good. if it’s set up right. Keying off the seat is a good way to do this.
Oh alright I’ll try it when I’m done, doing something at the moment
With that all you need to do is define the aircraft as the value of the object value. I would reccomend you set the value manually rather than using a script. This way you can reference the aircraft by the object value in your tool. The seat is programmed so that the tool is given or destroyed depending on if a player is seated or not. Also make surey ou reference your seat. You can just put that script into the seat. It should give the control when seated and remove it when a player gets up and walks. It may be better to connect to jumping or the explicit disconnect of the seat. But walking should work fine, the function is disconnected to prevent it firing more than once.
Like this?
You can try “script.Parent:FindFirstAncestor(“Aircraft”)
Doesn’t work because i made an Aircraft Tool that changes location to the backpack