I am trying to active the lights and the horn of a car upon a key press and it isn't working. Script inside of VehicleSeat:
local light1 = script.Parent.Parent.Lights.Main.Light1.SpotLight
local light2 = script.Parent.Parent.Lights.Main.Light2.SpotLight
local lightson = false
local seat = script.Parent
while seat.Occupant ~= nil do
local mouse = game.Players[seat.Occupant.Parent.Name]:GetMouse()
mouse.KeyDown:connect(function(key)
if key == "z" then
if lightson == false then
lightson = true
light1.Enabled = true
light1.Parent.Material = "Neon"
light2.Enabled = true
light2.Parent.Material = "Neon"
else
lightson = false
light1.Enabled = false
light1.Parent.Material = "SmoothPlastic"
light2.Enabled = false
light2.Parent.Material = "SmoothPlastic"
end
elseif key == "x" then
script.Parent.Horn:Play()
end
end)
mouse.KeyUp:connect(function(key)
if key == "x" then
script.Parent.Horn:Stop()
end
end)
end
