I don't know why

I don’t know why, but there’s an error at require(script.Parent.ModuleScript)


If anyone can help me, thank you!

2 Likes

You can place the ModuleScript inside of the Script and then reference it like so:

local moduleScript = require(script.ModuleScript)

It didnt work
The module script:

local module = nil

function module.getEngine()
return script.Parent.Engine
end
|||||||||||||||||||||||||||||||||||||||
The engine is a meshpart

Is the ModuleScript returning a value at all? If not, that’s why. You are attempting to index getEngine with nil.

local module = nil

function module.getEngine()
return script.Parent.Engine
end

local module = nil

function module (nil).getEngine()
return script.Parent.Engine
end

It helps to pay attention to what you’re actually writing. The solution would be the below.

local module = {}

function module.getEngine()
    return script.Parent.Engine
end

return module

Basically make module into a table and return it. That fixes the problem.

1 Like

i tried putting sound in the engine block. the main script would be like this

local module = require(script.Parent.ModuleScript)

local engine = module.getEngine()
engine.Sound:Play()

but the sound didn’t play. do you have an idea?

Did it return an error when the sound didn’t play?

i dont know, i deleted the engine model😅

also i made this:

game:GetService("RunService").Stepped:Connect(function()
	local pitch = math.abs(script.Parent.Parent.Parent.Base.CFrame:vectorToObjectSpace(script.Parent.Parent.Parent.Base.Velocity).Z)/20
	script.Parent.PlaybackSpeed = 0.75 * math.max(pitch, 0.5)
	local findseat, nonfound = pcall(function()
		script.Parent.Parent.Parent.VehicleSeat["SeatWeld"]:GetFullName()
	end)
	if findseat then
		script.Parent.Playing = true
	elseif nonfound then
		script.Parent.Playing = false
	end
end)

but i want it to like change gear like this:

It changed pitch every gear changes but I don’t like A-chassis anyways