In roblox, I am working on building a car using a-chassis. I am working on adding lights. I used a pre-existing script made by someone. I edited it a little and the remote events seems to not being working when I test it in 2 player mode. The scripts only work locally. I don't know a lot about remote events.

Explorer: https://ibb.co/rtkJpZH

Local Script:

local car = script.Parent.Parent.Parent.Car.Value
local mouse = game.Players.LocalPlayer:GetMouse()
car.DriveSeat:WaitForChild("Reverse")
if 	script.Parent.Parent.Parent.IsOn.Value then
	script.Parent.Parent:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
end

script.Parent.Parent.Parent.IsOn.Changed:connect(function()
	if script.Parent.Parent.Parent.IsOn.Value then
		script.Parent.Parent:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
	end
end)

	local handler = car.Lights
	
	script.Parent.MouseButton1Click:connect(function()
		if car.Body.Lights.L.L.L.Enabled == false then
			handler:FireServer("Lights",1)
			script.Parent.TextStrokeColor3 = Color3.new(0,255/255,0)
			car.Body.Lights.L.L.L.Enabled = true
			for index, child in pairs(car.Body.Lights.L:GetChildren()) do
			child.L.Enabled = true
			end
			for index, child in pairs(car.Body.Lights.DLR:GetChildren()) do
			child.Material = Enum.Material.Neon
			end
			for index, child in pairs(car.Body.Lights.R:GetChildren()) do
			child.Material = Enum.Material.Neon
			end
			for index, child in pairs(car.Body.Lights.H:GetChildren()) do
			child.Material = Enum.Material.Neon
			child.L.Enabled = true
			end

		elseif car.Body.Lights.L.L.L.Enabled == true then
			handler:FireServer("Lights",0)
			script.Parent.TextStrokeColor3 = Color3.new(0,0,0)
			car.Body.Lights.R.L.L.Enabled = false
			for index, child in pairs(car.Body.Lights.L:GetChildren()) do
			child.L.Enabled = false
			end
			for index, child in pairs(car.Body.Lights.DLR:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
			end
			for index, child in pairs(car.Body.Lights.R:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
			end
			for index, child in pairs(car.Body.Lights.H:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
			child.L.Enabled = false
			end
		end
	end)
	
	script.Parent.Parent.Parent.Values.Brake.Changed:connect(function()
		if script.Parent.Parent.Parent.Values.Brake.Value == 0 and script.Parent.Parent.Parent.IsOn.Value then
			handler:FireServer("Brake",0)
			for index, child in pairs(car.Body.Lights.B:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
			end
			car.Body.Lights.B.L.L.Enabled = false
		else
			handler:FireServer("Brake",1)
			for index, child in pairs(car.Body.Lights.B:GetChildren()) do
			child.Material = Enum.Material.Neon
			end
			car.Body.Lights.B.L.L.Enabled = true
		end
	end)
	
	script.Parent.Parent.Parent.Values.Gear.Changed:connect(function()
		if script.Parent.Parent.Parent.Values.Gear.Value == -1 then
			handler:FireServer("Reverse",1)
			car.DriveSeat.Reverse:Play()
			for index, child in pairs(car.Body.Lights.Rev:GetChildren()) do
			child.Material = Enum.Material.Neon
			end
		else
			handler:FireServer("Reverse",0)
			car.DriveSeat.Reverse:Stop()
			for index, child in pairs(car.Body.Lights.Rev:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
			end
		end
	end)
	
	while wait() do
		if (car.DriveSeat.Velocity.magnitude/40)+0.300 < 1.3 then
		car.DriveSeat.Reverse.Pitch = (car.DriveSeat.Velocity.magnitude/40)+0.300
		car.DriveSeat.Reverse.Volume = (car.DriveSeat.Velocity.magnitude/150)	
		else
		car.DriveSeat.Reverse.Pitch = 1.3
		car.DriveSeat.Reverse.Volume = .2
		end
	end

Remote Event Script:

local F = {}
local DriveSeat = script.Parent.Parent:WaitForChild("DriveSeat")
local car = DriveSeat.Parent

uis.InputBegan:connect(function(input, gp)
F.Lights = function(lights)
	if lights == 1 then
		car.Body.Lights.R.L.L.Enabled = true
		for index, child in pairs(car.Body.Lights.L:GetChildren()) do
			child.L.Enabled = true
		end
		for index, child in pairs(car.Body.Lights.DLR:GetChildren()) do
			child.Material = Enum.Material.Neon
		end
			for index, child in pairs(car.Body.Lights.R:GetChildren()) do
			child.Material = Enum.Material.Neon
		end
		for index, child in pairs(car.Body.Lights.H:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
			child.L.Enabled = true
		end
	elseif lights == 0 then
		car.Body.Lights.R.L.L.Enabled = false
		for index, child in pairs(car.Body.Lights.L:GetChildren()) do
			child.L.Enabled = false
		end
		for index, child in pairs(car.Body.Lights.DLR:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
		end
		for index, child in pairs(car.Body.Lights.R:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
		end
		for index, child in pairs(car.Body.Lights.H:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
			child.L.Enabled = false
		end
	end
end

F.Brake = function(brake)
	if brake == 0 then
		for index, child in pairs(car.Body.Lights.B:GetChildren()) do
			child.Material = Enum.Material.SmoothPlastic
		end
		car.Body.Lights.B.L.L.Enabled = false
	else
		for index, child in pairs(car.Body.Lights.B:GetChildren()) do
			child.Material = Enum.Material.Neon
		end
		car.Body.Lights.B.L.L.Enabled = true
	end
end

F.Reverse = function(reverse)
	if reverse == 1 then
		car.DriveSeat.Reverse:Play()
		for index, child in pairs(car.Body.Lights.Rev:GetChildren()) do
		child.Material = Enum.Material.Neon
		end
	else
		car.DriveSeat.Reverse:Stop()
		for index, child in pairs(car.Body.Lights.Rev:GetChildren()) do
		child.Material = Enum.Material.SmoothPlastic
		end
	end
	
end

script.Parent.OnServerEvent:connect(function(pl,Fnc,...)
	F[Fnc](...)
end)

2 comments

0

We aren't free model support

0

ii just idk