I realized after I wrote it I didnt have to check that it was true (Im very tired rn) LOL
I’ve never really used task.wait() so it almost always slips my mind but looking at what it does I guess it does make more sense to use it
I realized after I wrote it I didnt have to check that it was true (Im very tired rn) LOL
I’ve never really used task.wait() so it almost always slips my mind but looking at what it does I guess it does make more sense to use it
all these solutions arent working and nothing came out in the output
idk the difference between task.wait() and wait() either
but people use task.wait() more often
but i think task.wait() just doesn’t throttle or something
can you put a print statement inside the while loop
Try this:
If thats the case then your code is wrong you have to wait(15) then set whatever value is equal to true and inside write wait(3)
For example:
local spawnTime = false
wait(15)
spawnTime = true
while spawnTime do
local Clone = NPC:Clone()
Clone.HumanoidRootPart.CFrame = spawner.CFrame -- Move the HumanoidRootPart and not the Torso
Clone.Parent = workspace
wait(3)
end
According to this post task.wait() is more accurate as it is 2x faster
Side Note: According to an admin we should use task.wait() instead…
oh wait a second
is this a server script?
if so:
local rStorage = game:GetService("ReplicatedStorage")
local enemiesFolder = rStorage:WaitForChild("Enemies")
local NPCs = {
enemiesFolder.EnemyName,
-- add more if you will ever need to
}
local spawner = script.Parent
-- We are getting rid of the textlabel variable, as you cannot access player GUIs on server side, if you want to edit the text label dynamically, you need to use remote events.
local spawnable = false
task.wait(15)
spawnable = true
while spawnable do
local clone = NPCs.YourEnemy:Clone() -- i'm being too complicated i know, but if you'll ever be adding more enemies, i suggest having a function that's responsible for enemy RNG
clone.Parent = workspace
clone.HumanoidRootPart.CFrame = spawner.CFrame
task.wait(3)
end
oh it’s because it’s an array
okay so
you can either do
local NPCs = {
SomeName = enemiesFolder.YourEnemy
}
OR
NPCs[1]:Clone()
If you want a detailed explanation on how to clone mobs you can watch this GnomeCode video on tower defence stuff:
Wave Based Attacks - Tower Defense Tutorial #2 (youtube.com)
Just change the
local NPCs = {
enemiesFolder.killguy
}
to
local NPCs = {
killguy = enemiesFolder.killguy
}
In the first, you are calling a NPCs.killguy doesn’t exist, as there is no entry in the array NPCs called killguy. Your mistake was in not thinking through the information that the computer has access to. The computer will not magically find the killguy part that is under enemiesFolder, you need to tell it that that is the killguy NPC.
Consider marking this as a solution if your problem was solved.
the npc arent spawning in the position of the spawner
try
clone.PrimaryPart.CFrame = spawner:GetPivot()
If that doesn’t work, then see what print(spawner:GetPivot())
outputs.
they spawning in the floor and changing the Y value does nothing
Try
clone.PrimaryPart.CFrame = spawner:GetPivot()+Vector3.new(0,3,0)
just put it slightly above the ground
and instead of clone.PrimaryPart...
just do clone:SetPrimaryPartCFrame(spawner.CFrame)
SetPrimaryPartCFrame is depreacted
oh
i mean i still use it, so it can’t be that bad
i have done all those solutions
wont work
ughhh
any errors? can i see your code and explorer?