I made two scripts each for two lights on my aircraft to turn on and off using the keys "G" and "H" for Crazyman32's planekit. I'll provide the scripts below.
local tool = script.Parent
tool = PlaneKit.Plane.MainParts.MainSeat.Plane
tool.Equipped:connect(function(mouse)
mouse.KeyDown:connect(function(key)
if key == "H" then
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight1.PointLight.Enabled = true
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight1.Light.Enabled = true
if key == "H" then
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight1.PointLight.Enabled = false
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight1.Light.Enabled = false
end
end
end)
end)
local tool = script.Parent
tool = PlaneKit.Plane.MainParts.MainSeat.Plane
tool.Equipped:connect(function(mouse)
mouse.KeyDown:connect(function(key)
if key == "G" then
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight2.PointLight.Enabled = false
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight2.Light.Enabled = false
if key == "G" then
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight2.PointLight.Enabled = true
game.Workspace.PlaneKit.Plane.LandingGear.LandingLight2.Light.Enabled = true
end
end
end)
end)
These scripts have no errors inside them and I've made sure that they are correct. I go into the game to test my aircraft out and play around with the scripts. Now that's the problem. They don't work, I opened the developer console as an action of this and I received this but have no idea how to resolve this problem. "attempt to index global 'PlaneKit' (a nil value)" - Any ideas on how I can fix this?

2 comments
I used local scripts to prevent a previous error "Equipped is not a valid member of HopperBin" which occurred when I used scripts.
The PlaneKit doensn't simply exsist in Workspace. You should change "PlaneKit.Plane.MainParts.MainSeat.Plane" to "game.Workspace.PlaneKit.Plane.MainParts.MainSeat.Plane"