Hi, i have a script for spawn the monster in my area, all works good but recently i have add an invisible zone for make sound region, and my monster spawn above this zone it is possible to ignore collision of my monster with this invisible zone ? The cancollide is false so i don’t understand…
The script for spawn monster:
local spawner = game.Lighting["DogSS1.1"]:Clone()
local fox = script.Parent.SS1
local x,z = fox.Position.X,fox.Position.Z
x,z = math.random(x - r,x + r),math.random(z - r,z + r)
Y = (0)
local pos = Vector3.new(x,Y,z)
spawner.Parent = workspace
spawner:MoveTo(pos)
The monster don’t spawn in Y = 0 but Y = 120 cause due invisible zone…
Where is your code that checks if the monster is spawning within the forbidden zone?
It should look something like this:
if (monsterPosition.X < forbiddenZone.X or monsterPosition.X > forbiddenZone.X + forbiddenZone.Width) and (monsterPosition.Z < forbiddenZone.Z or monsterPosition.Z > forbiddenZone.Z + forbiddenZone.Length) then
spawnMonster()
Yeah but you have to do the same check then when spawning a monster. The condition in the if statement is what’s important.
I’m a bit confused about what you’re code exactly does. A tip for the future is adding some comments to your code and change variables to be more self explanatory.
Yes i understand but i want to spawn my monster in Y = 0, but with my invisible zone my monster spawn at Y = 120 due to monster spawn above my invisible zone ^^ with your code my monster won’t spawn ^^ and iw ant to spawn monster but in Y = 0 xD
If you want your monster to spawn within a can collide false part, you are going to need to give its model a primary part, and use Model:SetPrimaryPartCFrame() .
Position always sets the objects position on top of whatever it is within, where as CFrame will always set the position exact.