Help with move object

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 :confused: 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 =,Y,z)
			spawner.Parent = workspace

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
1 Like

I don’t have spawnmonster, my code above spawn the monster ^^ and it’s work without my invisible zone

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

Ah, so you want your monster to spawn inside the zone. Have you tried setting the zone and monsters in the same collision group and then turning off their collisions.

Yes i want to spawn my monster inside the zone ^^ i don’t have tried the collision group, i let’s try

1 Like

I have make this in the same collision group and uncheck CanCollide but the monster don’t spawn inside my zone :confused:

A script is necessary ? i have just set the same colision group in my zone and my monster but i don’t know if it’s necessary to make a script

You could probably place the code for it inside the script you showed in your question.

Can you help me for the code ? your link don’t give me a model i don’t understand :confused:

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.

1 Like

Thank you :slight_smile: it’s working now