This script attaches an orb to the front of the players face that charges, the problem however is that I am unable to move when I make the weld. I tried moving the

charging.Anchored = true

to after the weld, but that didn't help. I also tried just not anchoring the part. But then it disappears.

game.ReplicatedStorage.Custom.OnServerEvent:Connect(function(plr,mousehit,key)
	if key == "Blast" then
		local char = game.Players[plr.Name].Character
		local hum = char.Humanoid
        local root = char.HumanoidRootPart
        local charging = Instance.new("Part",workspace)
        charging.Shape = Enum.PartType.Ball
        charging.Material = Enum.Material.Neon
        charging.Size = Vector3.new(0.1,0.1,0.1)
        charging.BrickColor = BrickColor.new("Really red")
        charging.CanCollide = false
        charging.Anchored = true
	local weld = Instance.new("Weld", char.Head)
weld.Part0 = char.Head
weld.Part1 = charging
weld.C0 = char.Head.CFrame:inverse()
weld.C1 = char.Head.CFrame * CFrame.new (0,0,10)


	function charge()
		local chargingPart = charging:Clone()
		chargingPart.Parent = charging
		chargingPart.CanCollide = false
	    chargingPart.Shape = Enum.PartType.Ball
        chargingPart.Material = Enum.Material.Neon
        chargingPart.BrickColor = BrickColor.new("Really red")
        chargingPart.Size = Vector3.new(0.1,0.4,0.1)
        chargingPart.CFrame = charging.CFrame * CFrame.new(math.random(-0.6,0.6),math.random(-0.6,0.6),math.random(-0.6,0.6))
        chargingPart.Parent = charging
        chargingPart.Anchored = true
        game.Debris:AddItem(chargingPart,0.01)
	end
	    for i = 1,100 do
		spawn(charge)
		wait(0.01)
		
end
end
end)

2 comments

0

The parent argument to Instance.new is deprecated, and for the chargingPart assign the parent last.

0

Where is the instance.new deprecated?