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

Clone Script Will Not Clone My Victim?

What I want to happen

I've made an NPC script and I want it to clone so I made a spawner script that I found online and fixed it a bit.

Problem

Now It Won't Clone The Second Time So There Is A Problem With The While Loop.

Solutions

I Tried Changing The Name Of The Victim And Added Clone.Name So I Wanted To Test If Anything Happened. Nothing Did.

Script


local Victim = game.ReplicatedStorage.NPCFolder --ObjectNameHere
local spawner = script.Parent

while true do
	local Clone = Victim.NPC:Clone()
	Clone.Parent = workspace.NPC
	Clone.Name = "NPC"
	Clone.HumanoidRootPart.CFrame = spawner.CFrame
	wait(3)
end

1 answer

I don't know if it has much to do with this, but I noticed that you're not using a... wait what was it called again? ah yes, a debounce! anyways, just wanted to say that your "wait(3)" will probably not make it wait a while before being able to spawn another gremlin in.

local debounce = false

while true do
if not debounce then
    local Clone = Victim.NPC:Clone()
    Clone.Parent = workspace.NPC
    Clone.Name = "NPC"
    Clone.HumanoidRootPart.CFrame = spawner.CFrame
    wait(3)
debounce = false
end

it might work, not sure tho as I'm fairly new and this is just for adding a debounce...

1 comment

0

Now Your Debounce works only once, and it needs a wait. Also I added some fixes in your code

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