#help with player character anchoring, animations, cframe and unanchoring

1 messages · Page 1 of 1 (latest)

hexed ginkgo
#

So the player is driving a car, it enters a certain region, the player gets unseated and the car gets deleted. after this the player gets anchored and set to a cframe position, there an idle animation plays. After this when the player exits from this state I unanchor the player and place it at another CFrame position. At this point the players movement acts really weirdly and i can only slide around. the normal movement is gone, when i jump i can change directions and such but not when normally.

Server function

local function removePlayerFromGarage(player, garage)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    local humanoid = character:WaitForChild("Humanoid")
    local animator = humanoid:WaitForChild("Animator")

    -- Restore movement
    humanoid.WalkSpeed = 16
    humanoid.JumpPower = 50

    -- Unanchor and teleport to exit
    -- Server
    humanoidRootPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
    humanoidRootPart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
    character.PrimaryPart.CFrame = garage:FindFirstChild("ExitPoint").CFrame + Vector3.new(0, 3, 0)
    humanoidRootPart.Anchored = false
end

local function placePlayerInGarage(player, garage)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    local humanoid = character:WaitForChild("Humanoid")
    local animator = humanoid:WaitForChild("Animator")
    
    character.PrimaryPart.CFrame = garage:FindFirstChild("CharacterPart").CFrame + Vector3.new(0, 0, 0)
    humanoidRootPart.Anchored = true


    -- Disable default anims

    -- Play custom idle
    local idleAnim = Instance.new("Animation")
    idleAnim.AnimationId = "rbxassetid://118660748409131"
    local animTrack = animator:LoadAnimation(idleAnim)
    animTrack.Looped = true
    animTrack:Play()

    return animTrack, animScript -- return so you can stop/re-enable later
end
#

Client function

player.PlayerGui.GarageGUI.MainFrame.Main.Exit.Activated:Connect(function()
    RS.Events.CarRemove:FireServer(garage)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    local animator = humanoid:WaitForChild("Animator")
    
    for _, track in ipairs(animator:GetPlayingAnimationTracks()) do
        track:Stop(0)
    end

    local animScript = character:FindFirstChild("Animate")
    if animScript then animScript.Disabled = false end

    task.wait(0.1)
    
    humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
    
    player.PlayerGui.GarageGUI.MainFrame.Visible = false
    workspace.CurrentCamera.CameraSubject = player.Character.Humanoid
end)

function Load(Garage)
    --do some error handling here???
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    local humanoid = character:WaitForChild("Humanoid")
    local animator = humanoid:WaitForChild("Animator")
    garage = Garage


    -- Teleport
    local animScript = character:FindFirstChild("Animate")
    if animScript then animScript.Disabled = true end
    for i,v in ipairs(animator:GetPlayingAnimationTracks()) do
        v:stop(0)
    end
    player.PlayerGui:FindFirstChild("GarageGUI").Enabled = true
    humanoid.Sit = false
    CarRequest:FireServer(Garage)
    repeat
        workspace.CurrentCamera.CameraSubject = Garage:FindFirstChild("CameraPart")
        task.wait(0.1)
        print("cecking")
    until workspace.CurrentCamera.CameraSubject == Garage:FindFirstChild("CameraPart")
    print("done")
    task.wait(3)
    workspace.CurrentCamera.CameraSubject = Garage:FindFirstChild("CameraPart")
end
#

more client

function Load(Garage)
    --do some error handling here???
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    local humanoid = character:WaitForChild("Humanoid")
    local animator = humanoid:WaitForChild("Animator")
    garage = Garage


    -- Teleport
    local animScript = character:FindFirstChild("Animate")
    if animScript then animScript.Disabled = true end
    for i,v in ipairs(animator:GetPlayingAnimationTracks()) do
        v:stop(0)
    end
    player.PlayerGui:FindFirstChild("GarageGUI").Enabled = true
    humanoid.Sit = false
    CarRequest:FireServer(Garage)
    repeat
        workspace.CurrentCamera.CameraSubject = Garage:FindFirstChild("CameraPart")
        task.wait(0.1)
        print("cecking")
    until workspace.CurrentCamera.CameraSubject == Garage:FindFirstChild("CameraPart")
    print("done")
    task.wait(3)
    workspace.CurrentCamera.CameraSubject = Garage:FindFirstChild("CameraPart")
end

with this a remote event is triggered to the server that then calls the placeplayeringarage function

knotty swan
#

the only thing i can see that could maybe cause your physics bug or whatever is maybe the assembly velocity stuff. just anchor the humanoidrootpart and character:PivotTo(CFrame)

hexed ginkgo
vital ploverBOT
#

studio** You are now Level 1! **studio

knotty swan
#

LOLL

#

uh

#

yeah its probably the way you change assembly velocity

hexed ginkgo
#

no it stil does this

#

its definelty some problem with the car

knotty swan
#

well you made the scripts so you have a better understanding 😭 🤞

hexed ginkgo
#

but i goota clean this up first

knotty swan
#

well at the same time im no pro with roblox's forsaken physics

hexed ginkgo
#

okay i fixed it

knotty swan
#

noice