inside a folder in ReplicatedStorage called Zombies
Don’t use Move to(). Set the LowerTorso of the zombie’s CFrame to the teleport position.
I’m not familiar with operating CFrame, How would you go about doing this?
Would SetPrimaryPartCFrame() work?
Creating a CFrame with just a position is easy.
local c = CFrame.new(Vector3 position)
But how do you set CFrame to a model?
A few problems I see here.
- I’m gonna assume the structure of your zombie is in a model. You want to use the function:
Model:SetPrimaryPartCFrame(CFrame.new(SpawnPosition))
CFraming is more accurate but it won’t account for collisions so make sure that the spawn positions are accurate.
- For your probabilities I recommend doing something like this instead:
local zombProb = {0.01, 0.1, 0.2, 0.5, 1}
local num = math.random()
for k = 1, #zombProb do
if num < zombProb[k] then
spawnzomb(k)
break
end
end
No since the primary part of a character model is the HumanoidRootPart
In general, SetPrimaryPartCFrame is frowned upon for it’s gradual offsets.
I was struggling with the probabilities so I decided to sequentially generate the zombies instead. Thanks for the suggestion though!
(And thanks (hopefully) for a solution too!)
Setting the primarypart cframe should work in his case if he is just spawning the zombie in once. I don’t recommend doing that for animating the zombie; you would use the humanoid:moveto functions.
Sorry but that doesn’t work!
It still crashes when it tries to place the zombie into the map
remove the while loop and try it again. See if there are any errors, or crashing
Well no. My objection wasn’t with using SetPrimaryPartCFrame in this specific scenario (it wouldn’t matter since the Motor6Ds would fix it). It was just to let him know there are better solutions. My objections was with the fact that moving a character in general involves changing the root of the Motor6Ds CFrame.
Still crashes without the while loop.
AH! Once you kill the script, the zombie is spawned and working!?
What’s going on here?
I’ve figured it out!
There is a script in the zombie that has a While True do loop WITH NO WAITS!
It must have been lagging the game so much that it crashes!
Just a stupid mistake by me, sorry for wasting your time everyone!
Remember to mark a solution so that others know this problem was fixed for you, and that they may have a similar necessary solution.
Yes I marked my comment as a solution