Issue with spawn()

Hello fellow developers, so I’ve been starting to make an attack recently, but the issue is that my spawn function doesn’t work. Here’s what I mean, I want my vfx to spin and grow at the same time, for this I made a repeating loop for the spin (so it doesnt go infinitely) and then used the spawn function and after that I wrote my tween, the problem is that the tween plays and then the vfx spins, heres my script:

script.Parent.OnServerEvent:Connect(function(plr)
	print("Fired Rengoku Attack")
	local char = plr.Character
	local hum = char.Humanoid
	local root = char.HumanoidRootPart
	local vfx = game.Lighting.BulletVFX:Clone()
	local ts = game:GetService("TweenService")
	vfx.CFrame = root.CFrame
	vfx.Parent = workspace
	
	local function spinvfx()
		for i = 1,1800 do
			vfx.CFrame = vfx.CFrame * CFrame.fromEulerAnglesXYZ(0,0.5,0)
			wait()
		end
	end
	
	spawn(spinvfx)
	
	local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0)
	local properties = {
		Size = Vector3.new(26, 80, 30);
		CFrame = vfx.CFrame * CFrame.new(0,40,0)
	}
	ts:Create(vfx,info,properties):Play()
end)

And heres a video showing the issue:
https://gyazo.com/53520900ed938ea0bc54828a64445f18

Any help is appreciated, thank you!

Spawn is generally not recommended, as its delay would get rather significant as your game gets bigger. I suggest using coroutine.

im not sure what you are trying to do whit spawn by itself but you might want to take a look at this

coroutine.wrap might be the solution you are looking for

Still doesn’t seem to be working, is there anything wrong?

script.Parent.OnServerEvent:Connect(function(plr)
	print("Fired Rengoku Attack")
	local char = plr.Character
	local hum = char.Humanoid
	local root = char.HumanoidRootPart
	local vfx = game.Lighting.BulletVFX:Clone()
	local ts = game:GetService("TweenService")
	vfx.CFrame = root.CFrame
	vfx.Parent = workspace
	
	local spinvfx = coroutine.wrap(function()
		for i = 1,1800 do
			vfx.CFrame = vfx.CFrame * CFrame.fromEulerAnglesXYZ(0,0.5,0)
			wait()
		end
	end)
	
	spinvfx()
	
	local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0)
	local properties = {
		Size = Vector3.new(26, 80, 30);
		CFrame = vfx.CFrame * CFrame.new(0,40,0)
	}
	ts:Create(vfx,info,properties):Play()
end)
script.Parent.OnServerEvent:Connect(function(plr)
	print("Fired Rengoku Attack")
	local char = plr.Character
	local hum = char.Humanoid
	local root = char.HumanoidRootPart
	local vfx = game.Lighting.BulletVFX:Clone()
	local ts = game:GetService("TweenService")
	vfx.CFrame = root.CFrame
	vfx.Parent = workspace
	
	coroutine.wrap(function()
		for i = 1,1800 do
			vfx.CFrame = vfx.CFrame * CFrame.fromEulerAnglesXYZ(0,0.5,0)
			wait()
		end
	end)()
	
	local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0)
	local properties = {
		Size = Vector3.new(26, 80, 30);
		CFrame = vfx.CFrame * CFrame.new(0,40,0)
	}
	ts:Create(vfx,info,properties):Play()
end)

try this

I’m still getting the same result where it completes the tween and then spins, should I just put a spin script in its own script and insert it into the vfx?

you could try that im not really into making animation

Okay! Thank you for your help.