I’m making a silly cart game, but here’s the thing, I made a tool that makes explosions at the target location, but should a cart be exploded, it just wont respawn!
local a = script.Parent.Parent.Cart:clone()
local deb = false
function chng()
if deb == true then return end
deb = true
local new = a:clone()
new.Parent = script.Parent.Parent
new:MakeJoints()
script.Parent.BrickColor = BrickColor.new(21)
wait(6)
script.Parent.BrickColor = BrickColor.new(28)
deb = false
end
script.Parent.Click.MouseClick:connect(chng)
This is a script that came with the model, I want to repurpose it so if it does not find the cart, then it creates one from thin air or whatever. The cart is a model.
local event = script.Parent.Fire
local handle = script.Parent.Handle
local screen = handle.Screen
local ragdollMgr = require(game.ReplicatedStorage.RagdollSystem)
event.OnServerEvent:Connect(function(player, pos)
screen.Color = Color3.fromRGB(38, 255, 0)
local explosion = Instance.new("Explosion")
explosion.Parent = workspace
explosion.Visible = true
explosion.Position = pos
explosion.BlastRadius = 13
explosion.BlastPressure = 1000000
explosion.DestroyJointRadiusPercent = 0
local blastRadius = explosion.BlastRadius
local visual = Instance.new("Part",workspace)
visual.CanCollide = false
visual.Anchored = true
visual.CastShadow = false
visual.Transparency = 0.15
visual.Shape = "Ball"
visual.Size = Vector3.new(25,25,25)
visual.Color = Color3.fromRGB(226, 132, 0)
visual.Material = Enum.Material.Neon
visual.Position = pos
explosion.Hit:Connect(function(OtherPart, distance)
if OtherPart.Parent ~= workspace and OtherPart.Parent.Name ~= "Handle" then
if game.Players:GetPlayerFromCharacter(OtherPart.Parent) then
local char = OtherPart.Parent
ragdollMgr.Ragdoll(char)
char.Humanoid:TakeDamage(999999999999999)
else
local welds = OtherPart.Parent:GetDescendants()
for i,v in pairs(welds) do
if v:IsA("Weld") or v:IsA("WeldConstraint") then
v:Destroy()
end
end
end
end
end)
game.Debris:AddItem(explosion,0.5)
game.Debris:AddItem(visual,0.51)
end)
This is my tool script. How do I get it to destroy carts, but atleast make them respawnable?