Updating CFrame doesn't want to work

I’m trying to teleport a player but when I update the CFrame the request seemingly gets blocked as there is no error.
Script (ModuleScript load_map function called by a LocalScript

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.CFrame = CFrame.Angles(math.rad(angle_X), math.rad(angle_Y), math.rad(angle_Z))
end

end

};

return functions;

I tried troubleshooting it and I found the out the command bar can change the CFrame but the LocalScript can’t. I’m wondering if they updated Roblox so that CFrames can’t be changed locally.

It looks like you’re setting the position in the first line, then over-writing it in the second.

Try doing this instead:

local pos = CFrame.new(spawn_area_X, spawn_area_Y, spawn_area_Z)
local rot = CFrame.Angles(math.rad(angle_X), math.rad(angle_Y), math.rad(angle_Z))
character.HumanoidRootPart.CFrame =  pos * rot
1 Like

Yeaaaaaaa it worked thanks a lot. Strange thing tho is that it worked before and the script was exactly like how it was before. That happens to a lot of my scripts actually, the just decide not to work. Strange.

1 Like