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

"Spawn function requires 1 argument", but ive already given it an argument?

Im trying to work with moving a vehicle. Im not looking into Motor6D's right now, im just fiddling with some stuff on my own. Im trying to see if I can execute this while loop function at the same time as another, and for that im trying to use the "spawn()" function. However, I always get the error, "Spawn function requires 1 argument." Here is my code:

local MoveVehicle = function(MoveTo)
	local TweenProperties = {
		CFrame = Vehicle.CFrame * MoveTo
	}
	local Tween = TweenService:Create(Vehicle,TweenInfo,TweenProperties)
	Tween:Play()
	CurrentTween = Tween
end

spawn(MoveVehicle(CFrame.new(0,0,-100)))

There is much more, but these are the only relevant sections. As far as I can tell im passing the Function "MoveVehicle" as the argument for the built-in function "spawn", so I honestly have no clue whats happening here.

1 answer

That is passing in more than 1 argument. Use this code instead of line 10

spawn(function()
	MoveVehicle(CFrame.new(0,0,-100))
end)

This spawns a function with 1 argument that then runs another function with a CFrame argument rather than trying to pass two arguments into a spawn function.

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