I placed a LocalScript inside a VehicleSeat, and what I'm trying to do is that when the player sits, it can execute the following function.
local Seat = script.Parent -- Path to seat
local LightPart = script.Parent.Parent.LightParts
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local on = false
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant ~= nil then
Mouse.KeyDown:connect(function(key)
if key == "l" then
if on == true then
on = false
LightPart.HeadLightPart.Material = Enum.Material.SmoothPlastic
LightPart.HeadLightPart2.Material = Enum.Material.SmoothPlastic
else
LightPart.HeadLightPart.Material = Enum.Material.Neon
LightPart.HeadLightPart2.Material = Enum.Material.Neon
end
end
end)
end
end)

12 comments
Are you sure that you tried it out?
Yes I did. Prints out an error?
It didn't work at all
Did it print out an error?
No, it didn't, but it didn't work at all
Try to put a print() after every line, and check if the code even runs
it can be placed inside of a localscript of a VehicleSeat, right?
I put a print() after every line
No it can't, use a ServerScript
wdym ServerScript? Do you mean ServerScriptService?
No, normal script
And I edited my answer, Iposted a LocalScript version of it