CFrame take 12 numbers.The first three numbers are the Position and the nine others are for the rotation.
You can set a CFrame like this:
local part = Instance.new("Part", workspace)
part.Anchored = true
part.CFrame = CFrame.new(10, 5, 10)
for set the position its not really hard you can use CFrame.Angles or again CFrame.fromEulerAnglesXYZ
in theses function you'll need to put the rotation you want to have for the part.
We'll take the exemple from later an change it.
local part = Instance.new("Part", workspace)
part.Anchored = true
part.CFrame = CFrame.new(10, 5, 10) *CFrame.Angles(0, math.pi/2, 0)
math.pi mean 90 degree, if you remove / 2 It'll be 180 degree.
The number ?(pi) is a mathematical constant, the ratio of a circle's circumference to its diameter, commonly approximated as 3.14159.
But you dont really need math.pi for set the rotation you can use math.rad another function in the math library.
local part = Instance.new("Part", workspace)
part.Anchored = true
part.CFrame = CFrame.new(10, 5, 10) *CFrame.Angles(0, math.rad(90), 0)
It'll does like later nothing change excepted your code.
For CFrame.fromEulerAnglesXYZ Its the same thing as CFrame.Angles but CFrame.Angles is shorter and more easy to remember :3.You can also go on wiki if you want to know more on CFrame.
Now let's fix your code.
this part you've made take three position in a position you have three number(X, Y, Z) so we'll take these number and change it.You're error:
script.Parent.CFrame = CFrame.new(char.Torso.Positon, char.Head.Position + 1, char.Torso.Position)
and now It'll look like this
script.Parent.CFrame= CFrame.new(char.Torso.Position.X, char.Head.Position.Y + 1, char.Torso.Position.Z)
for your code its really simple you'll only need to change ^this part for the emplacement of your error.
Your code fix.
function onPlayerEntered(player)
player.CharacterAdded:connect(function(char)
while wait() do
script.Parent.CFrame= CFrame.new(char.Torso.Position.X, char.Head.Position.Y + 1, char.Torso.Position.Z)
end
end)
end
game.Players.PlayerAdded:connect(onPlayerEntered)
PS.: I see another error from your grammar from Positon you just need to change it for Position, a grammar error can be fatal in your code :s.
2 comments
Does not work
Work now