Hello !
Trying to make a part (custom explosion) that destroy every part when it touches it, or if it’s a player, kill him, Code :
local TS = game:GetService("TweenService")
local TweenI = TweenInfo.new(1.5)
local goalSize = {}
local explosion = script.Parent
goalSize.Size = script.Parent.Size + Vector3.new(250,250,250)
local TweenPlay = TS:Create(explosion, TweenI, goalSize)
TweenPlay:Play()
script.Parent.Explosion:Play()
TweenPlay.Completed:Wait()
script.Parent:Destroy()
script.Parent.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if not hum then
-- if not string.find(hit.Name, "Safe") then
game.ReplicatedStorage.Regen:Fire(hit, hit.Parent)
wait(0.1)
hit:Destroy()
-- end
else
hum.Health = 0
end
end)
Script is a server script, Disabled (Enabled via another script)
When connecting events the first thing that gets returned is the LocalPlayer if it’s being fired to the server, you’ll need to add an extra argument at the beginning.
game.ReplicatedStorage.Regen.Event:Connect(function(_, part, parent)
if part:IsA("BasePart") then
part.Parent = game.ServerStorage.Temporary
print(part.Parent.Name)
wait(10)
part.Parent = parent
print(part.Parent.Name)
end
end)