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

Why is my VehicleSeat localscript not working?

Asked by 4 years ago

Basically, I am trying to make my cars' lights turn on by pressing L, but when I tested it, It didn't function at all.

Script:

local Headlight = script.Parent.Parent.Parent.LightParts.HeadLightPart
local SurfaceLight = script.Parent.Parent.Parent.LightParts.HeadLightPart.SurfaceLight

local input = game:GetService("UserInputService")
    input.InputBegan:Connect(function(Key)
    if Key.KeyCode == Enum.KeyCode.L then
        Headlight = Enum.Material.Neon
        SurfaceLight.Brightness = 5
    else
        Headlight = Enum.Material.SmoothPlastic
        SurfaceLight.Brightness = 0
    end
    end
0
Make sure you're using a LocalScript, as Server Scripts don't work for UserInputService, gamernight687 138 — 4y
0
LocalScripts won't run when you parent them to a part. You need to parent yours to StarterPlayerScripts or such. Also use remote events if you want other players to be able to see the lights too Amiaa16 3227 — 4y
0
why not type it out on answers. Gam3r_Play3r 47 — 4y

Answer this question