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

how to make the variable wait for one child at multiple times?

local rock = script.Parent:WaitForChild("newRock") -- help me with this line



function onTouched(hit)
    local humanoid =hit.Parent:FindFirstChildWhichIsA("Humanoid")
    if humanoid ~= nil then
        print(humanoid)
        humanoid:TakeDamage(100)
    end
end

rock.Touched:Connect(onTouched)


the newrock is a clone and i want the rock variable to wait for the another clones, any help?

" the cloning script "

local rock = script.Parent.Part

local function copyRock()
	local newRock = rock:Clone()
	newRock.Name = "newRock"
	newRock.Anchored = false
	newRock.Parent = script.Parent
	wait(5)
	newRock:Destroy()
end




while true do
	wait(1)
	copyRock()
end

1 comment

0

Is it giving you any errors?

1 answer

I'm not sure if this will work or not, but it's worth a try.

local rockSpawned = false
local rock = script.Parent.newRock

while rockSpawned == false do
	if rock then
		rockSpawned = true
	end
	wait(0.1)
end

I believe this would make the script be stuck in a loop until "newRock" is cloned

1 comment

0

Replace the top line with this ^^

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