So basically when a character levels up, the sound gets instanced into him and plays it once everything works here.

BUT i got a GUI which deletes all stats for the player, so when he deletes them the sound instances from 2 to 6 sounds sometimes less, more, why does this happen ? also how can u spawn the parts without the loop ?

ting = false

function onLevelUp(player, XP, level)
	if player.Character~=nil then 
		if ting == false then
		ting = true
		local levelupsound = Instance.new("Sound")
		levelupsound.Parent = player
		levelupsound.SoundId = "" --not gonna show mah sound.
		levelupsound.Volume = 0.5
		levelupsound.Pitch = 1
		levelupsound:Play()
		game:GetService("Debris"):AddItem(levelupsound, 10)
		for i = 1,5 do 
			local fireworks = Instance.new("Part")
			fireworks.CanCollide = false
			fireworks.Material = "Neon"
			fireworks.Shape = 0
			fireworks.formFactor = "Symmetric"
			fireworks.Size = Vector3.new(2,2,2)
			fireworks.BrickColor = BrickColor.Random() 
			fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,4,0)
			fireworks.Parent = game.Workspace
			game:GetService("Debris"):AddItem(fireworks, 3.5)
			fireworks.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
		ting = false
		end
	end
end
end

1 comment

0

Anyone ?