Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why the script isn't doing anything when i try to clone a ball?

I want to spawn a cloned part but is not spawning. I don't get any error but when i remove "wait(1000)" it works and crashes my roblox studio. Also i want it to spawn random between 2 parts, but i don't know how to do it, maybe someone could help me.

Script:

local part = workspace.Handle
local Event = game.ReplicatedStorage.Fire

local Entitati = 0
local SpawnEntitati = true


while SpawnEntitati == true do
	if Entitati <= 50 then
		wait(1000)
		print("Ai asteptat 1000 minisecunde (o secunda)")
		local cpart = part:Clone()
		cpart.Parent = workspace
		cpart.Position.X = part.Position.X
		cpart.Position.Y = part.Position.Y + 1
		cpart.Position.Z = part.Position.Z
		print("Part creat.")
		Event:FireAllClients(cpart)
		print("RemoteEvent Fire")
	end
	if Entitati >= 50 then
		SpawnEntitati = false
		print("Spawn entitati = false")
	end
end

Also i tried this code to spawn random between 2 parts:

local part = workspace.Handle
local Event = game.ReplicatedStorage.Fire
local pos1 = workspace.pos1
local pos2 = workspace.pos2

local Entitati = 0
local SpawnEntitati = true


while SpawnEntitati == true do
	if Entitati <= 50 then
		wait(1000)
		print("Ai asteptat 1000 minisecunde (o secunda)")
		local cpart = part:Clone()
		cpart.Parent = workspace
		cpart.Position = math.random(pos1.Position, pos2.Position)
		print("Part creat.")
		Event:FireAllClients(cpart)
		print("RemoteEvent Fire")
	end
	if Entitati >= 50 then
		SpawnEntitati = false
		print("Spawn entitati = false")
	end
end

Photo

IS NOT A LOCALSCRIPT.

edit: Thanks both for helping me. Thought it was in miliseconds :D

2 answers

✓ Accepted answer

You are waiting for 1000 seconds. You need to change the

 wait()

to the number you want in seconds.

You're waiting for one thousand seconds, not miliseconds!

Wait takes a number in seconds as its argument. Otherwise it waits for three miliseconds, 0.03 seconds.

This discussion is preserved as it was. New answers, comments, and votes are closed.