New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

How in the heck would I do this? (Is this specific enough, title bot?)

Asked by 3 months ago

If I 'elaborated on my question' my title would be way too long.

Basically, this scriptinghelpers post tells me that, in order to make car headlights, I must place a RemoteEvent inside the car, a LocalScript in an unspecificed location, and a script inside the car. I've put the LocalScript in the RemoteEvent. It needs to be somewhere in the car because the car is referred to as 'script.Parent.Parent' several times. I can't say 'game.Workspace...' because, should my game get any traction, there will be several people driving the same type of car. RemoteEvents require LocalScripts, don't they? LocalScripts must be in a player to work, right? So, how can I have a RemoteEvent connected to a local script which is inside a car? If that isn't possible, how can I have a RemoteEvent perform its function with a script that is inside of a car? How can I make car headlights with FE?

Here are the scripts, if you need them:


local player = game:GetService("Players").LocalPlayer
local HondaAccordWagon = script.Parent.Parent.Parent.Parent
local Headlights = script.Parent.Parent.Headlight1
local UIS = game:GetService("UserInputService")

    if inputObject.KeyCode == Enum.Keycode.L then
        Headlights.HeadlightLight1.Enabled = not Headlights.HeadlightLight1.Enabled
        Headlights.Headlight2.HeadlightLight2.Enabled = not Headlights.Headlight2.HeadlightLight2.Enabled


Normal script:

local HondaAccordWagon = script.Parent.Parent
local headlights = false

    headlights = not headlights
    if headlights then
        script.Parent.HeadlightLight1.Enabled = true
        script.Parent.Headlight2.HeadlightLight2.Enabled = true
        script.Parent.Headlight2.HeadlightLight2.Enabled = false
        script.Parent.HeadlightLight1.Enabled = false

Yes, I stole the scripts from the aforementioned scriptinghelpers post. Do I feel bad at all? Nope.

a local script HAS to be a child of the player, it will not run if it is in the workspace. Fad99 278 — 3mo
yes it will? KDarren12 690 — 3mo
Okay, great, but I need it to be there because it MUST reference 'script.Parent.Parent' and not 'game.Workspace....' How would I make a set of headlights using FE and by referencing 'script.Parent.Parent' and not 'game.Workspace...."? sesamert16 29 — 3mo
To make your game future proof: There should be ONE local script in StarterPlayer. There should be ONE Remote event in ReplicatedStorage. Server should know which car player is in, and act accordingly. sleazel 759 — 3mo
View all comments (2 more)
Sleazel, with your setup, how do I reference the cars? sesamert16 29 — 3mo
I would need to see your car script, but I assume the driver only is able to switch the lights? So the server should know when driver enter/leaves car. Then you update, lets say a dictionary in module script in server storage, index is the player, value is the car. Once remote event fires, server looks up player in the dictionary and switches lights in car if there is any. sleazel 759 — 3mo

Answer this question