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

Clone Script Will Not Clone My Victim?

Asked by 2 years ago

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

Log in to vote
0
Answered by
pwgth 11
2 years ago

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...

0
Now Your Debounce works only once, and it needs a wait. Also I added some fixes in your code Brioche_Noodle 45 — 2y
Ad

Answer this question