I need to get when it touches something so that it can create an explosion but it only seems to work on the player. also it only works once.
--Creates a projectile spell
-- This one is work in progress
function SpellModule.Proiciol(Vars)
local ProjectilePart = Instance.new("Part")
ProjectilePart.Parent = Vars["Player"].Character
ProjectilePart.Anchored = true
ProjectilePart.CanCollide = false
ProjectilePart.Size = Vector3.new(2,2,2)
ProjectilePart.Shape = Enum.PartType.Ball
ProjectilePart.CFrame = Vars["Player"].Character.PrimaryPart.CFrame + Vars["Player"].Character.PrimaryPart.CFrame.LookVector
local Range = 5
local ProjectileRunService = RunService.Stepped:Connect(function(RunServiceTime, deltaTime)
ProjectilePart.CFrame = ProjectilePart.CFrame + (RunServiceTime * .1 * ProjectilePart.CFrame.LookVector) -- Makes projectile go in direction of look vector
ProjectilePart:GetTouchingParts(function(parts)
print(parts)
end)
ProjectilePart.Touched:Connect(function(Toucher)
print("Touched")
if Toucher and Toucher.Parent:FindFirstChild("Humanoid") == false then
print("GO")
local Explosion = Instance.new("Explosion")
Explosion.Parent = ProjectilePart
end
end)
--Destorys projectile if out of range
if RunServiceTime > Range and ProjectilePart then
ProjectilePart:Destroy()
end
end)
end