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

How to easily move all parts of a character on the server?

Asked by
lolzmac 207 Moderation Voter
4 years ago

I've made a bed that lays the player down on it after a keypress, and anchors the humanoid's rootpart, but the issue is that whenever I move the rootpart, the server does not move the rest of the character with it.

The client appears to lay down without any issues, but the server has not acknowledged the parts attached to the rootpart, making the character on the server appear to float. The rootpart has moved, but just not the rest. What can I do to fix this?

If you need it, here's my server script code:

local function onBed(player, bed, char)
    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/asset/?id=03568388195"
    local animationTrack = char.Humanoid:LoadAnimation(animation)
    char.Humanoid.RootPart.Anchored = true 
    animationTrack:Play()
    char.Humanoid.RootPart.Position = bed.Position + Vector3.new(0, 2, 0)
    char.Humanoid.RootPart.Orientation = bed.Orientation
end
0
Use the RootPart's CFrame. DeceptiveCaster 3761 — 4y

1 answer

Log in to vote
0
Answered by
bluzorro 417 Moderation Voter
4 years ago

You can use SetPrimaryPartCFrame, which moves all parts of a model, if the model has a primary part.

local function onBed(player, bed, char)
    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/asset/?id=03568388195"
    local animationTrack = char.Humanoid:LoadAnimation(animation)
    char.HumanoidRootPart.Anchored = true
    animationTrack:Play()
    char:SetPrimaryPartCFrame(bed.CFrame +  CFrame.new(0, 2, 0))
end
Ad

Answer this question