Making a map loading script. I am making the character change orientation on spawn but rotating the humanoid root part doesnt seem to be the right way to do it the character starts to face weird directions.
I tried bodygyro and that doesnt work and i tried changing cframe instead of vector3 and that doesnt work.
ReplicatedStorage = game.ReplicatedStorage
loaded_map = script.Parent.loaded_map.Value
local_map_storage = ReplicatedStorage.local_map_storage
maps = game.Workspace.maps
maps_children = maps:GetChildren()
storage_children = local_map_storage:GetChildren()
Terrain = game.Workspace.Terrain
local functions = {
load_map = function (area, spawn_area_X, spawn_area_Y, spawn_area_Z, angle_X, angle_Y, Angle_Z, use_respawn, transition, transition_name, transition_description, transition_colour)
print (area.." loaded")
ReplicatedStorage.load_area:FireServer(area, spawn_area_X, spawn_area_Y, spawn_area_Z)
maps[loaded_map].Parent = local_map_storage
loaded_map = area
local_map_storage[area].Parent = maps
local map_terrain = maps[loaded_map].terrain
local cubes = map_terrain.cubes:GetChildren()
local spheres = map_terrain.spheres:GetChildren()
for i = 1, #cubes do
local cube_child = cubes[i]
if cube_child:IsA("Part") then
game.Workspace.Terrain:FillBlock(cube_child.CFrame, cube_child.Size, Enum.Material[cube_child.Name])
end
end
if use_respawn == true then
print ("Using respawn points.")
else
local character = game.Players.LocalPlayer.Character
character.HumanoidRootPart.CFrame = CFrame.new(spawn_area_X,spawn_area_Y,spawn_area_Z)
character.HumanoidRootPart.Orientation = Vector3.new(angle_X,angle_Y,Angle_Z)
end
end
};
return functions;
^ LocalScript
:SetPrimaryPartCFrame() didn’t work. Also I’m not using spawn locations because there are multiple maps in my game and it would just teleport me to random places.
I just need someone to tell me how to properly rotate a character