I have a script for a long-range attack and I want to make it create an explosion anytime it collides with ANYTHING because right now, it only explodes when players are directly hit, and just phases through everything else.
I’ve searched far and wide and couldn’t seem to find anything that would help me do this, I’ve only seen people explain how to create explosions when collisions between specific parts occur, but that’d be pretty difficult to do seeing as my map has like 5k of them. Thank you :slight_smile: Here’s the current code i’m using:
if Switch.Value == false then Ki.Parent = Cac.Humanoid Ki.CFrame = Cac.HumanoidRootPart.CFrame Ki.Position = RHand.Position Switch.Value = true Cac.Humanoid:LoadAnimation(script.Parent.Parent.Animation):Play() local sound = script["Ki blast"]:Clone() sound.Parent = Ki sound:Play() sound.Script.Disabled = false local Part = Ki game.Debris:AddItem(Part, 6) local HRP = Player.Character:WaitForChild("HumanoidRootPart") local PPosition = RHand.Position + CFrame.new(RHand.Position,Mouse.p).lookVector * 1 Part.CFrame = CFrame.new(PPosition, Mouse.p) Part:SetNetworkOwner(Player) local BV = Instance.new("BodyVelocity" , Part) BV.Velocity = HRP.CFrame.LookVector * 140 BV.MaxForce = Vector3.new(1e8,1e8,1e8) wait(4) Part:destroy() return end
i dk how to do that but i know how to make a killing block
First you would need to make the script that detects when you touch it.
Script:
local part = script.Parent -- replace this with your part part.Touched:Connect(function(hit) print('part is toutching ', hit.Name) -- will become explosion script later end)
That script will print "part is touching [other thing]" in the console
Now we need to work on the explosion
We will need to get the Position of the part first so add this line after printing
local partPos = part.Position
(Btw name the variables anything you want it doesn't matter)
We will also need to create an explosion so add that line as well
local explosion = Instance.new('Explosion')
After that we parent it to your part and set its Position to the part's Position
explosion.Position = partPos explosion.Parent = part
Finally after the explosion we delete your part
wait(1) part:Destroy()
Heres the final script! (Note that if the part is touching something already it will trigger the explosion)
local part = script.Parent -- replace this with your part part.Touched:Connect(function(hit) print('part is toutching ', hit.Name) local partPos = part.Position local explosion = Instance.new('Explosion') explosion.Position = partPos explosion.Parent = part wait(1) part:Destroy() end)