Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i change the rotation of a players torso without killing them ?

Asked by
lyxture 27
7 years ago

this is a local script in the players backpack

while true do wait()
game.Workspace.Model.Torso.Rotation = script.Parent.Parent.Character.Torso.Rotation
end

2 answers

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

Use CFrames instead. They're pretty complex so i suggest reading through this wiki page. http://wiki.roblox.com/index.php?title=CFrame


while wait() do local rot = script.Parent.Parent.Character.Torso.Rotation game.Workspace.Model.Torso.CFrame = CFrame.new(game.Workspace.Model.Torso.Position) * CFrame.Angles(math.rad(rot.X),math.rad(rot.Y),math.rad(rot.Z)) end
0
i know how to use cframes and used it alot but i dont know how to use cframe to change the other person rotation that matches the exact same ad mine lyxture 27 — 7y
0
oh wait nvm lyxture 27 — 7y
Ad
Log in to vote
3
Answered by 7 years ago
Edited 7 years ago

CFrame

When you're dealing with setting the position or rotation of a part, you should always use CFrame. While the Position and Rotation property of all BaseParts are able to be written to, you should treat them as read-only. I'm not going to write out a tutorial on CFrame here, but I will give you the rundown.

Creating a CFrame

A new CFrame object can be created with the CFrame.new constructor. There are several different constructors for creating different CFrames, but for now, you can treat it just like Vector3.new in terms of passing XYZ coordinates. Example:

local newCFrame = CFrame.new(0, 5, 0) -- New CFrame object, with coordinates: X:0, Y:5, Z:0

Setting CFrame

You can set a CFrame object to the hidden CFrame property of a part. I say hidden, because the CFrame property isn't shown in the properties window in studio. But it's there nonetheless. Example:

local newCFrame = CFrame.new(0, 5, 0)

-- Assuming 'part' represents a BasePart
part.CFrame = newCFrame

Rotation

Instead of rotation being a different property, it's a form of manipulating a CFrame object. There's a constructor called CFrame.Angles which you can multiply with a CFrame object created with CFrame.new. It may sound like a lot to take in at once, but trust me, you'll get it down pretty fast.

Radians

You should also note that rotation is given in radians. To put radians into perspective, and to save some time explaining them, pi (3.14...) is a number in radians that can represent half a rotation. You can access this value in Lua's math library as math.pi. Example implementing rotation:

local newCFrame = CFrame.new(0, 5, 0)
local newRotation = CFrame.Angles(0, math.pi, 0) -- Create new rotation that rotates 180 degrees on the Y axis.

-- Set the CFrame of the part to the product of both position and rotation
part.CFrame = newCFrame * newRotation

That's the basic rundown on CFrame and rotation. If you have any questions, just let me know and I'll get back to you as soon as possible.

0
you go overkill on everything. gees.. RubenKan 3615 — 7y

Answer this question