This script is supposed to explode (which uses a part not Roblox explosions) when touching anything other than the player or ball but instead when the ball is thrown it spawns a bunch of parts at the position. If the part is set to set humanoid health to 0 when touched even though the parts are all the way across the map it kills the player.
local rep = game:GetService("ReplicatedStorage")
local ball = rep.Ball
local gravity = -100 -- negative numbers
local fastcast = require(rep.Dependencies.FastCastRedux)
local caster = fastcast.new()
local behavior = fastcast.newBehavior()
local tool = script.Parent
local remoteEvent = game.ReplicatedStorage.Throw
toolball = nil
characther = nil
local params = RaycastParams.new()
remoteEvent.OnServerEvent:Connect(function(plr, mousePos, plrStrength)
characther = plr.Character or plr.CharacterAdded:Wait()
toolball = plr.Character.Dodgeball
print(characther)
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {toolball, characther}
behavior.RaycastParams = params
behavior.Acceleration = Vector3.new(0, gravity, 0)
behavior.AutoIgnoreContainer = true
behavior.CosmeticBulletTemplate = ball
behavior.CosmeticBulletContainer = characther
local speed = plrStrength
local pos = toolball.Handle.CFrame * CFrame.new(0,0,-50)
local direction = (mousePos - toolball.Handle.Position).Unit
caster:Fire(toolball.Handle.Attachment.WorldPosition,direction, speed, behavior)
end)
caster.LengthChanged:Connect(function(ActiveCast, lastPoint, rayDir, displacement, segmentVelocity, cosmeticBulletObject)
local newPos = lastPoint + (rayDir * displacement)
cosmeticBulletObject.Position = newPos
end)
caster.RayHit:Connect(function(ActiveCast, RaycastResult, segmentVelocity, cosmeticBulletObject)
local explosion = Instance.new("Part", workspace)
explosion.Position = RaycastResult.Position
explosion.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
end)