So I made two scripts that help make an explosion effect on models when clicked on.
However the explosion doesn’t feel very satisfying, I’d like a spherical explosion effect but my script just unanchored and :ApplyImpule() into a random direction.
Local Script:
local mouse = game.Players.LocalPlayer:GetMouse()
local destruction = game.ReplicatedStorage:WaitForChild("Destruction")
mouse.Button1Down:Connect(function()
local target = mouse.Target
if target and target:FindFirstAncestorOfClass("Model") then
for _, v in pairs(target.Parent:GetDescendants()) do
destruction:FireServer(v)
print(v.Name)
end
else
if target.Name ~= "Baseplate" then
target.Anchored = false
destruction:FireServer(target)
print(target.Name)
end
end
end)
Server Script:
local destruction = game.ReplicatedStorage:WaitForChild("Destruction")
destruction.OnServerEvent:Connect(function(player, part)
local character = player.Character or player.CharacterAdded:Wait()
local torso:Part = character:WaitForChild("Torso")
if part and part:IsA("Part") then
part.Anchored = false
local orientation, size = part.Parent:GetBoundingBox()
print(orientation.p)
for _, v:Part in pairs(workspace:GetPartBoundsInRadius(orientation.p, 2)) do
v:ApplyImpulse((v.Position - orientation.p)*50)
end
end
if part and part:IsA("ManualWeld") then
print(part.Name)
part:Destroy()
end
end)
Demonstration: