How to have a script changing the horsepower of an A-Chassis car?

I’m making a car that drives slower when being offroad but the first thing I need working is the changing of the horsepower done by a script. I made this server script:

local tune = require(script.parent["A-Chassis Tune"])
tune.Horsepower = 50

The problem is that the A-Chassis Tune module script is not changing.
I want the car slow down, so could anyone help me with this?

Convert the module that has the “settings” in it to use NumberValues instead of variables within the script.

In other words, instead of:

tune.Horsepower = 50

Load the value from a NumberValue:

tune.Horsepower = script.Horsepower.Value

That way to can change the values at any time from other scripts.

1 Like

Still doesn’t change the module script.

Make something like:

Module:

-- A-Chassis Tune module
local Tune = {}

Tune.Horsepower = 100 -- Default horsepower value

return Tune

Script:

-- Server script
local Tune = require(script.Parent["A-Chassis Tune"])

-- Modify horsepower
Tune.Horsepower = 50

That was exactly what I have but doesn’t work.

The Module Script named A-Chasiss Tune contains all the values for the vehicle.

It uses variables that are assigned within the script itself. Such as:

Tune.LoadDelay = 3.0

Screen Shot 2024-03-15 at 3.28.01 PM

I am suggesting that you rework the script to call the values from Instances stored within the ModuleScript.

Like this:

Screen Shot 2024-03-15 at 3.25.52 PM

That way you can access those values at any time and change those values at any time without ever needing to access the ModuleScript.

Try it with Horsepower and see it it works. If it does then update the entire Module Script.