Hi, I’m beginner script writing. I been struggle to clone sound (from ServerScriptService) into landmine then destroy in case of lag.
I did try clone() but it didn’t work.
local ServerStorage = game:GetService("ServerStorage")
local CollectionService = game:GetService("CollectionService")
local bombSound = ServerStorage["Bomb Sound"]
local function makeLandmine(hitbox)
hitbox.Touched:Connect(function(hit)
local character = hit:FindFirstAncestorWhichIsA("Model")
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
local explosion = Instance.new("Explosion")
explosion.Position = hitbox.Position
explosion.Parent = workspace
for _, v in pairs(hitbox.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 1
v.CanCollide = false
end
end
hitbox:Destroy()
end
end
end)
end
for _, landmine in pairs(CollectionService:GetTagged("Landmine")) do
makeLandmine(landmine)
end