Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

NOS for a drift car?

So I'm wanting to add NOS for my drift car and it is most definitely possible, but my script doesn't seem to work. I have an A-Chassis Tune script and I'm wanting a button to be able to change the Horsepower set inside the A-Chassis Tune script and a sound to play when the NOS is activated. I currently have a Frame for the button inserted to the Plugins folder of the A-Chassis Tune script and inside the Frame is a button with a local script saying:

local car = script.Parent.Parent.Parent.Parent.Parent
local NOS = car.Body.NOS
local Tune = {}
local HP = Tune.Horsepower

script.Parent.MouseButton1Click:Connect(function()
	HP = 500
	print("HP Changed to 500")
	wait(5)
	HP = 350
	print("HP Reset")
	wait(0.5)
	script.Parent.Active = false
	script.Parent.Text = "NOS Refueling"
	wait(20)
	script.Parent.Text = "NOS Refueled"
	wait(2)
	script.Parent.Text = "NOS Ready"
end)

But I don't think that this script can access the Horsepower setting from a different script. How can I change my horsepower from a different script?

1 comment

0

A chassis hp is a script value, not a physical object. It's like HP = 350. Try adding a int value in a-Chassis script and in the hp line in a chassis just put HP = script.HP.Value.

1 answer

So I figured it out thanks to personal_ly for helping me!

If you want to add nitrous to your car, then find your A-Chassis script, open it, scroll down TO THE BOTTOM and find the end of this script:

		
	--Keyboard Controls
		--Mode Toggles
		ToggleTCS				= Enum.KeyCode.T					,
		ToggleABS				= Enum.KeyCode.Y					,
		ToggleTransMode			= Enum.KeyCode.M					,
		ToggleMouseDrive		= Enum.KeyCode.R					,
		
		--Primary Controls
		Throttle				= Enum.KeyCode.Up					,
		Brake					= Enum.KeyCode.Down					,
		SteerLeft				= Enum.KeyCode.Left					,
		SteerRight				= Enum.KeyCode.Right   	   	        ,
	
		--Secondary Controls
		Throttle2				= Enum.KeyCode.W 					,
		Brake2					= Enum.KeyCode.S					,
		SteerLeft2				= Enum.KeyCode.A 	 				,
		SteerRight2				= Enum.KeyCode.D					,
		
		--Manual Transmission
		ShiftUp					= Enum.KeyCode.E  			      	,
		ShiftDown				= Enum.KeyCode.Q					,
		Clutch					= Enum.KeyCode.P    	        	,
		
		--Handbrake
		PBrake					= Enum.KeyCode.LeftShift	        ,
		
	--Mouse Controls
		MouseThrottle			= Enum.UserInputType.MouseButton1	,
		MouseBrake				= Enum.UserInputType.MouseButton2	,
		MouseClutch				= Enum.KeyCode.W					,
		MouseShiftUp			= Enum.KeyCode.E					,
		MouseShiftDown			= Enum.KeyCode.Q					,
		MousePBrake				= Enum.KeyCode.LeftShift			,
		
	--Controller Mapping
		ContlrThrottle			= Enum.KeyCode.ButtonR2				,
		ContlrBrake				= Enum.KeyCode.ButtonL2				,
		ContlrSteer				= Enum.KeyCode.Thumbstick1			,
		ContlrShiftUp			= Enum.KeyCode.ButtonY				,
		ContlrShiftDown			= Enum.KeyCode.ButtonX				,
		ContlrClutch			= Enum.KeyCode.ButtonR1				,
		ContlrPBrake			= Enum.KeyCode.ButtonL1				,
		ContlrToggleTMode		= Enum.KeyCode.DPadUp				,
		ContlrToggleTCS			= Enum.KeyCode.DPadDown				,
		ContlrToggleABS			= Enum.KeyCode.DPadRight			,
	}

When you find the end of that, change it to this:

	--Keyboard Controls
		--Mode Toggles
		ToggleTCS				= Enum.KeyCode.T					,
		ToggleABS				= Enum.KeyCode.Y					,
		ToggleTransMode			= Enum.KeyCode.M					,
		ToggleMouseDrive		= Enum.KeyCode.R					,
		
		--Primary Controls
		Throttle				= Enum.KeyCode.Up					,
		Brake					= Enum.KeyCode.Down					,
		SteerLeft				= Enum.KeyCode.Left					,
		SteerRight				= Enum.KeyCode.Right   	   	        ,
	
		--Secondary Controls
		Throttle2				= Enum.KeyCode.W 					,
		Brake2					= Enum.KeyCode.S					,
		SteerLeft2				= Enum.KeyCode.A 	 				,
		SteerRight2				= Enum.KeyCode.D					,
		
		--Manual Transmission
		ShiftUp					= Enum.KeyCode.E  			      	,
		ShiftDown				= Enum.KeyCode.Q					,
		Clutch					= Enum.KeyCode.P    	        	,
		
		--Handbrake
		PBrake					= Enum.KeyCode.LeftShift	        ,
		
	--Mouse Controls
		MouseThrottle			= Enum.UserInputType.MouseButton1	,
		MouseBrake				= Enum.UserInputType.MouseButton2	,
		MouseClutch				= Enum.KeyCode.W					,
		MouseShiftUp			= Enum.KeyCode.E					,
		MouseShiftDown			= Enum.KeyCode.Q					,
		MousePBrake				= Enum.KeyCode.LeftShift			,
		
	--Controller Mapping
		ContlrThrottle			= Enum.KeyCode.ButtonR2				,
		ContlrBrake				= Enum.KeyCode.ButtonL2				,
		ContlrSteer				= Enum.KeyCode.Thumbstick1			,
		ContlrShiftUp			= Enum.KeyCode.ButtonY				,
		ContlrShiftDown			= Enum.KeyCode.ButtonX				,
		ContlrClutch			= Enum.KeyCode.ButtonR1				,
		ContlrPBrake			= Enum.KeyCode.ButtonL1				,
		ContlrToggleTMode		= Enum.KeyCode.DPadUp				,
		ContlrToggleTCS			= Enum.KeyCode.DPadDown				,
		ContlrToggleABS			= Enum.KeyCode.DPadRight			,
	}
	local Cooldown = false
	local Using = false
	local UserInputService = game:GetService("UserInputService")
	UserInputService.InputBegan:connect(function(input,gameProcessed)
		if not gameProcessed then 
			if input.KeyCode == Enum.KeyCode.N and Cooldown == false and Using == false then
				Using = true
				print("Player pressed N")
				 Tune.Horsepower = 1000 --SET THIS TO THE HP YOU WANNA BOOST                                                                            AT
				delay(5,function()
					Tune.Horsepower = 400  --SET THIS TO YOUR DEFAULT HP
					Cooldown = true
					Using = false
					spawn(function()
						wait(1)
						Cooldown = false
					end)
				end)

			
			end
		end	
	end)
	

Nitrous should work with the N key!

This discussion is preserved as it was. New answers, comments, and votes are closed.