Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I link a light control through a vehicle seat?

Asked by 7 years ago

Hey, I am trying to script the headlights on a school bus. I have buildboard GUI's as the lights. I am using key inputs ("L") for the light block. It's in a local script in the vehicle seat, why do my lights not work?

--[[
Light = Buildboard GUI
"HL_" = Headlight
"BL_" = Brakelights (4 of them)
"Engine" = The model SOME lights are in
--]]

local mouse = game.Players.LocalPlayer:GetMouse()
function onKeyDown(key)
    if key == "l" then
            script.Parent.Body.HLL.Light.Enabled = true
            script.Parent.Body.HLR.Light.Enabled = true
            script.Parent.Body.Engine.BLL.Light.Enabled = true
            script.Parent.Body.Engine.BLR.Light.Enabled = true
            script.Parent.Body.Engine.BTL.Light.Enabled = true
            script.Parent.Body.Engine.BTR.Light.Enabled = true
        else
            script.Parent.Body.HLL.Light.Enabled = false
            script.Parent.Body.HLR.Light.Enabled = false
            script.Parent.Body.Engine.BLL.Light.Enabled = false
            script.Parent.Body.Engine.BLR.Light.Enabled = false
            script.Parent.Body.Engine.BTL.Light.Enabled = false
            script.Parent.Body.Engine.BTR.Light.Enabled = false
    end 
end
mouse.KeyDown:connect(onKeyDown)
0
why are you using the mouse if the script is suppose to be activated by pressing "L"? Nogalo 148 — 7y
0
Key Down is deprecated. I recommend using Context Action Service because it allows you to easily disable the key binding and makes a button on mobile automatically. Here is a good tutorial on the roblox wiki: http://wiki.roblox.com/index.php?title=ContextActionService_tutorial User#15461 0 — 7y

Answer this question