Hello, im trying to make a spell in my game that shoots multiple shards out. Unfortunately i dont know how to make the object for the shard get spawned multiple times. The current code i have simply shoots out one if i left click. Here's the code.
--Force Shard
local shard = game.ServerStorage.Spells:WaitForChild("Shard")
local hurtSound = game.ReplicatedStorage:WaitForChild("Hurt")
game.ReplicatedStorage.Shard.OnServerEvent:Connect(function(player)
local character = player.Character
local newShard = shard:Clone()
newShard.CFrame = character.RightHand.CFrame
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(5000,5000,5000)
bodyVelocity.Velocity = (character.HumanoidRootPart.CFrame.lookVector*100)
bodyVelocity.Parent = newShard
newShard.Parent = workspace
newShard.CanCollide = true
local touchConn
local shardDMG = player.PlayerData.ShardDMG.Value
local deBounceIce = false
touchConn = newShard.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
hurtSound:Play()
if not deBounceIce then
deBounceIce = true
hit.Parent.Humanoid:TakeDamage(15 + shardDMG)
deBounceIce = false
end
if touchConn ~= nil then touchConn:Disconnect() end
newShard:Destroy()
end
end
end)
wait(2)
if touchConn ~= nil then touchConn:Disconnect() end
newShard:Destroy()
end)
