I’m making an RPG game that spawns an arena to fight the boss at a random position when you touch a button. Then, you get TP’ed to the arena, along with the boss. However, I want to ensure you get TP’ed and spawn at a certain location inside the part’s bounds. I want to make it so the player spawns 5% farther away from the start of the arena. I want to position the player without considering the orientation of the arena.
The -Z direction is forward. -X is left +X is right. From your pictures it looks like you want to move your character in the +Z direction, but your calculation moves the character in the negative X direction.
So, maybe you want something like this:
Do you want the player to rotate with the arena or always look into the screen?
I’m guessing you want to rotate with the arena, since the starting place will do that.
Then something like this:
local Mapa =workspace.Baseplate
local char:Model =script.Parent
local min, max = 0, 1000
local alcance = 100
--local Mobclone = Mob:Clone()
local Mapclone = Mapa:Clone()
Mapclone.Color = Color3.new(0, 0.333333, 0)
--local Map = Mapclone.Mapa
local rx, ry, rz
local GetPartBounds
repeat
rx, ry, rz = math.random(min, max), math.random(min, max), math.random(min, max)
ry = 10
GetPartBounds = workspace:GetPartBoundsInBox(CFrame.new(rx, ry, rz), Vector3.new(alcance, alcance, alcance))
until not next(GetPartBounds)
local Pos = Vector3.new(rx, ry, rz)
Mapclone.Parent = workspace
--Mapclone:MoveTo(Pos)
Mapclone:PivotTo(CFrame.new(Pos) * CFrame.Angles(0,math.pi,0))
local Position = Mapclone.Position
local Size = Mapclone.Size
--local PX, PY, PZ = Position.X, Position.Y+15, Position.Z + Size.Z/2-Size.Z * .05
local PX, PY, PZ = 0, 15, Size.Z/2-Size.Z * .05
local plrspawner = Vector3.new(PX, PY, PZ)
char:PivotTo(Mapclone:GetPivot() * CFrame.new(plrspawner))
With this code the player should always spawn across from the front or 5% from the rear. Note: some of the changes were just so it would be testable in a new workspace, so ignore those.