i'm trying to spawn a killbrick in a certain area but it isn't working .
local Rs = game:GetService("ReplicatedStorage")
local damagepart =Rs.damage
local cooldown = false
local plate = game.Workspace.plate.CFrame
local X,Y,Z = plate.X , plate.Y , plate.Z
local debris = game:GetService("Debris")
while true do
local clone =damagepart:Clone()
clone.Parent = game.Workspace
clone.CFrame = CFrame.new(math.random(0-X,X),0.5,math.random(0-X,X))*plate
task.wait(0.2)
debris:AddItem(clone,10)
clone.Touched:Connect(function(hit)
local player = hit.Parent:FindFirstChild("Humanoid")
if player and not cooldown then
cooldown = true
player.Health = 0
end
cooldown = false
end)
end