I tried to make a spawner that spawns a tool (a pink cube) randomly in a radius around the spawner but the cube doesnt move and doesnt spawn randomly
--// Variables
local cframeX = workspace.testSpawner.Position.X
local cframeY = workspace.testSpawner.Position.Y
local cframeZ = workspace.testSpawner.Position.Z
local randomspawn = Vector3(math.random(cframeX - 20, cframeX + 20), cframeY + 20, math.random(cframeZ -20, cframeZ + 20))
local randomspawntimer = math.random(5, 8)
local numb = 0
local canSpawn = true
local Workspace = game.Workspace
local PinkCube = Workspace:WaitForChild('PinkCube')
local PinkSpawner = workspace.testSpawner
--// Main
while true do
if canSpawn then
if numb <= 25 then
canSpawn = false
local PCC = PinkCube:Clone()
PCC.Parent = PinkSpawner
PCC.Handle.Position = Vector3(math.random(cframeX - 20, cframeX + 20), cframeY + 20, math.random(cframeZ -20, cframeZ + 20))
wait(randomspawntimer)
canSpawn = true
numb = numb + 1
end
end
end
end

3 comments
There are so much wasted lines here
I just copied his code and fixed what was wrong. It wasn't trying to remove the lines or optimize his code.
I wasn't*