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

Car light kit for A chasiss is not working. Why?

Asked by 3 years ago

Hello. I made some cars in blender, and I wanted to add a light kit. In my older cars the light kit is working correctly, but even if I copy all things from my older car it's still not working. When I hit "Lights" they should change from "auto" to "on" but then they are transparent and only SpotLight appears. Please help!

1 answer

Log in to vote
0
Answered by
azobo 4
3 years ago

My recommendation is to create another light model and add a spotlight. After that, if you want to make it a functional headlight, I just make the part neon when it is on, and glass with 0.2 transparency when it is off. I just do this to turn them on (just note that you may have to add more parents to get your headlight.

These next two scripts go in the GUI for the car. Headlight GUI Button on script (example) Script.parent.mousebutton1click:connect(function() Script.parent.parent.headlights.Material = “Neon” script.parent.parent.headlights.transparency = 0 Script.parent.parent.headlights.spotlight.enabled = true Script.parent.parent.headlights.Autolights.disabled = true script.parent.text = "Lights Off" Script.parent.off.disabled = true —This script changes the status of the off script (another script in the button) to make it enabled— Script.disabled = true

Headlight GUI Button off script (example) Script.Parent.MouseButton1Click:connect(function() Script.parent.parent.headlights.material = “Glass” Script.parent.parent.headlights.transparency = 0.2 Script.parent.parent.headlights.spotlight.enabled = false Script.parent.parent.headlights.autolights.disabled = false script.parent.text = "Lights On" Script.parent.on.disabled = false Script.disabled = true End)

Place this auto lights script into the Headlights model While true do Wait(0.01) If game.lighting.clocktime == 16.4 then Script.parent.material = "Neon" script.parent.transparency = 0 script.parent.spotlight.enabled = true end If game.lighting.clocktime == 7.5 then script.parent.material = "Glass" script.parent.transparency = 0.2 script.parent.spotlight.enabled = false end end)

What these scripts do is in the GUI, the on script will change the headlight material and transparency, and it will enable the spotlight, and at the same time, it will disable the on script and enable the off script in the button. It will also change the Auto Lights script in the headlights to false so if they are off or on, the Auto Lights script will not override the player's choice for the headlights. The Off script will change the transparency and material of the headlight, and disable the spotlights, and it will enable the Auto Lights script. The auto lights script will check the Clock Time (If the game has a day/night changer) every 0.01 seconds, and if the time is equal to the time the lights go on in the script, the script will change the lights transparency and material of the lights, as well as enable the spot light. And when the time is equal to the time the lights turn off in the script, the script will change the lights transparency and material, as well as turning the spotlights off. You can do the same thing for this if you want brake lights to turn on as well as the headlights. I hope this helped out!

0
I Will test it tommorow. Thank you for helping :D MarcinekSt 10 — 3y
0
Aaaaand it didn't work, but thank you :) MarcinekSt 10 — 3y
0
Your welcome. Maybe can you send me a video or something so I can see what happened? azobo 4 — 3y
Ad

Answer this question