toObjectSpace is a method of the CFrame type which performs a calculation - it doesn't actually modify the object that it was called on. This means that when you use a colon to call that method on a CFrame object, it will actually return a value for you to use.
I'll make a few suggestions about how to get your head around this problem.
#Finding the Character
Whilst playerone will point to the Model belonging to plr with your current code on line 4, this is a rather cumbersome and unnecessarily complicated way of getting a reference to the character. You should use this instead:
local playerone = plr.Character
#Rotating the Character
By default, ROBLOX does some very fancy manipulation with humanoids and player characters to achieve consistent physics and behaviour across very diverse games. If the player is using mouse lock, first person mode, or they are moving a lot, then setting the CFrame of the HumanoidRootPart will only set the rotation for a very brief moment before the default ROBLOX scripts change it back to something else.
Because of this, you might want to investigate more sophisticated methods for rotating, such as updating rotation with the RenderStepped event of RunService or using BodyGyro to physically rotate the player. If you just want to face the character in an initial direction, then your technique of setting the CFrame directly will do the trick.
#Facing Another Player
There is a special constructor of the CFrame type which takes two arguments (pieces of data). The first argument is the starting position, and the second is the position to look towards. If I wanted to make a new CFrame at position a which faces position b I would use:
new_cframe = CFrame.new(a, b)
Since you want to make a player face another, you can make a new CFrame with the starting position as one player and the position to face towards as the other player.
root_part_one = playerone.HumanoidRootPart
root_part_two = playertwo.HumanoidRootPart
root_part_one.CFrame = CFrame.new(root_part_one.Position, root_part_two.Position)
root_part_two.CFrame = CFrame.new(root_part_two.Position, root_part_one.Position)
I'd suggest having a look at this CFrame tutorial for more information.
3 comments
when you say "default Roblox script" does that mean if they dont move, because they'll be anchored for 5 seconds before they can move.
If you are anchoring the players before setting the rotation then there's no problem. By 'default ROBLOX scripts' I meant the scripts that define player behaviour, which often manipulate the orientation of the player and you sometimes have to be careful to synchronise or override that behaviour when rotating.
-- how to make aimbot