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?
You don't have anything in workspace called PlaneKit. Are you using a local script? If yes, try using a script.
In line 2 in both scripts, you attempt to index Planekit
, but Planekit
was never defined anywhere in the script. That's the problem; either you remove that line, or you change Planekit
to game.Workspace.Planekit
or something like that. Hope this helped!