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

How do you change the CFrame of a Player?

Asked by
KenzaXI 166
9 years ago

Hi I made a script which when a Player other then the carrier touches the part it deals them 30 Damage and sends them flying back whilst rotating, But I don't know how to change the CFrame of a Player can you help me Please?

local WindSphere = script.Parent
WindSphere.Touched:connect(function(Brick)
    local Hum = Brick.Parent:findFirstChild("Humanoid")
    local Player = game:GetService'Players'.LocalPlayer
    if (Hum ~= nil)then
        Hum.Health = Hum.Health - 30
        Player.CFrame = 0  -- I know that's how how you do it, so I'm leaving it like that on purpose
    end
end)

0
instead of player.CFrame you would have to do something like, Player.Vector3.new = 0 something like that duckyo01 120 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

You have to change the CFrame of the torso. Since all the limbs are welded to the torso the entire character will move:

local WindSphere = script.Parent
WindSphere.Touched:connect(function(Brick)
    local Hum = Brick.Parent:findFirstChild("Humanoid")
    local Player = game:GetService'Players'.LocalPlayer
    if (Hum ~= nil)then
        Hum.Health = Hum.Health - 30
        Player.Character.Torso.CFrame = CFrame.new(1,1,1)
    end
end)

0
You can also use MoveTo() which will move the whole character ObscureEntity 294 — 9y
0
Erm, How do you do so the Cframe is added, E.g if the CFrame is 3,3,3 I want to add 0,2,0 to it, but without doing it manually all the time, so I don't keep having to type in a new position, it just sends them that way KenzaXI 166 — 9y
Ad

Answer this question