Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
MpAlex 16
3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

 wait()

to the number you want in seconds.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

Answer this question