Drowning in infinite yields

Hi I’m trying to get an attachment called particles and I have tried variables, waitforchild, findfirstchild, even just normal “instance.instance” but I either get particles is not a member of instance or infinite yield of particles somebody please help this is my code: local repStorage = game:GetService(“ReplicatedStorage”)
local runService = game:GetService(“RunService”)
local Debris = game:GetService(“Debris”)
repStorage.Fireball.OnServerEvent:Connect(function(player, mouse)
local char = player.Character

local fireBlast = repStorage.Fireblast:Clone()
fireBlast.Parent = workspace.Ignore

fireBlast.CFrame = char.HumanoidRootPart.CFrame
local connection
local startTime = os.clock()
connection = runService.Heartbeat:Connect(function(dt)
	fireBlast.CFrame = CFrame.new((fireBlast.Position)+mouse.LookVector*dt*60)
	if os.clock() >= startTime+3 then
		connection:Disconnect()
		fireBlast:Destroy()
		local particles = fireBlast:WaitForChild("Particles")
		for i, v in pairs(particles:GetChildren()) do
			v.Enabled = false
		end
		Debris:AddItem(fireBlast, 3)
		return
	end
end)

end)
I can provide my other scripts if needed. I am using a tool that enables a remote event.

1 Like

The script trying to get particles.
But before this line to write:

fireBlast:Destroy()
1 Like

Try this solution script:

local repStorage = game:GetService("ReplicatedStorage")
local runService = game:GetService("RunService")
local Debris = game:GetService("Debris")
repStorage.Fireball.OnServerEvent:Connect(function(player, mouse)
	local char = player.Character

	local fireBlast = repStorage.Fireblast:Clone()
	fireBlast.Parent = workspace.Ignore

	fireBlast.CFrame = char.HumanoidRootPart.CFrame
	local connection
	local startTime = os.clock()
	connection = runService.Heartbeat:Connect(function(dt)
		fireBlast.CFrame = CFrame.new((fireBlast.Position)+mouse.LookVector*dt*60)
		if os.clock() >= startTime+3 then
			connection:Disconnect()
			local particles = fireBlast.Particles
			for i, v in pairs(particles:GetChildren()) do
				v.Enabled = false
			end
			Debris:AddItem(fireBlast, 3)
			return
		end
	end)

end)

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