This is the script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local boulderSpawner = workspace:WaitForChild("Boulder Spawner")
local ragdollBallTemplate = ServerStorage:WaitForChild("RagdollBall")
-- Get the RemoteEvent
local spawnBouldersEvent = ReplicatedStorage:WaitForChild("Spawn100Boulders")
-- Function to spawn boulders
local function spawnBoulders()
for i = 1, 100 do
local size = boulderSpawner.Size
local position = boulderSpawner.Position
local randomX = math.random(-size.X / 2, size.X / 2)
local randomZ = math.random(-size.Z / 2, size.Z / 2)
local spawnPosition = Vector3.new(position.X + randomX, position.Y - (size.Y / 2 + ragdollBallTemplate.Size.Y / 2), position.Z + randomZ)
local ragdollBall = ragdollBallTemplate:Clone()
ragdollBall.Position = spawnPosition
ragdollBall.Parent = workspace
wait(0.5) -- Wait for 0.5 seconds between each spawn
end
end
-- Connect the RemoteEvent to the spawn function
spawnBouldersEvent.OnServerEvent:Connect(function(player)
print(player.Name .. " triggered the boulder spawn.") -- Debug message
spawnBoulders()
end)