Changing the Parent doesn't actually change the Parent?

When cloning an object and changing its parent, it changes the parent if you check it in the script (aka using print(.Parent)) but it doesnt actually change the parent. I ran into this issue earlier trying to make an inventory system where I couldnt parent a tool into the player’s backpack. Now I can’t parent this clone of a particle in the workspace into a folder in the workspace. I have tried using wait()'s and have checked to see if the script is running properly. This is the only script in the place.

local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")

local Start = workspace.Start
local Finish = workspace.Finish
local Particle = workspace.Particle

local Bezier = function(Percent: number, CurvePosition: Vector3)
	local FirstLerp = Start.Position:Lerp(CurvePosition, Percent)
	local SecondLerp = CurvePosition:Lerp(Finish.Position, Percent)
	return FirstLerp:Lerp(SecondLerp, Percent)
end

local SpawnParticles = function()
	local OriginCFrame = Start.CFrame
	local RingRadius = 10
	local CountPerRing = 10
	local TravelTime = 1.5
	for Count = (360/CountPerRing), 360, (360/CountPerRing) do
		task.spawn(function()
			local RingParticle = Particle:Clone()
			task.wait(1)
			RingParticle.Position = Start.Position
			RingParticle.Parent = workspace
			print(RingParticle.Parent)
			local CurvePosition = (OriginCFrame * CFrame.Angles(0, math.rad(Count), 0)).LookVector * RingRadius
			for Percent = 0, 1, 0.1 do
				local BezierPosition = Bezier(Percent, CurvePosition)
				local Tween = TweenService:Create(RingParticle, TweenInfo.new(0.1), {Position = BezierPosition})
				Tween:Play()
			end
			RingParticle:Destroy()
		end)
	end
end

local LastRan = tick()
RunService.Heartbeat:Connect(function(DeltaTime)
	if tick() - LastRan > 5 then
		SpawnParticles()
		LastRan = tick()
	end
end)

Can you see particles on screen. If not your destroying them too soon.

Ah thank you. I forgot that :Play() doesn’t yield

1 Like

No worries, destroy after tween.completed

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.