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

3 comments

0

Make sure you're using a LocalScript, as Server Scripts don't work for UserInputService,

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

0

why not type it out on answers.