I’ve been trying to debug this for an hour now and i cannot find out why.
I really want to teleport the player and keep his orientation/rotation.
Reason why i didn’t move the humanoidRootPart is because it experienced some issues and glitched out the player for no reason and put him out of proportion.
-- Get the player and their current position and orientation
local player = game.Players.LocalPlayer
local currentPosition = player.Character.HumanoidRootPart.Position
local currentOrientation = player.Character.HumanoidRootPart.Orientation
-- Define the range of coordinates for the random teleport
local minX = -50
local maxX = 50
local minY = 5
local maxY = 20
local minZ = -50
local maxZ = 50
-- Generate random coordinates within the defined range
local newX = math.random(minX, maxX)
local newY = math.random(minY, maxY)
local newZ = math.random(minZ, maxZ)
-- Teleport the player to the new location while keeping orientation
player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(newX, newY, newZ), Vector3.new(currentOrientation.x, currentOrientation.y, currentOrientation.z))
Works but i cannot use humanoidrootpart cause it messes with the character. My friend said my character was put out of proportion. I used primarypart of the characters model and it’s still reversed for some reason
-- Get the model you want to move
local model = game.Workspace.YourModelNameHere
-- Define the target location
local targetPosition = Vector3.new(x, y, z) -- Replace x, y, and z with the desired coordinates
-- Move the model to the target location
model:SetPrimaryPartCFrame(CFrame.new(targetPosition))
-- Get the model you want to move
local model = game.Workspace.YourModelNameHere
-- Define the target position and the current orientation of the model
local targetPosition = Vector3.new(x, y, z) -- Replace with desired target position
local currentOrientation = model.PrimaryPart.CFrame:toEulerAnglesXYZ()
-- Create a new CFrame with the target position and the original orientation
local newCFrame = CFrame.new(targetPosition) * CFrame.Angles(currentOrientation.x, currentOrientation.y, currentOrientation.z)
-- Apply the new CFrame to the model's primary part
model:SetPrimaryPartCFrame(newCFrame)
You could just refer to the previous code I sent, pretty much the same thing