#Humanoid snapping to position after animation?

247 messages · Page 1 of 1 (latest)

magic patio
#

Basically I have an animation in my game, after it plays the humanoid is meant to teleport to a specific spot. However, it seems to go there for a millisecond, then weirdly, it snaps back to its original position? I don't understand why this is happening, below is my code and a video

local character = game.Workspace.mainbacon
local event3 = game.ReplicatedStorage.BombEvent


local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")


event.Event:Connect(function(plr)
    
    local animation = Instance.new("Animation")
    animation.AnimationId = "rbxassetid://74795693307326"
    local animTrack = animator:LoadAnimation(animation)
    animTrack.Priority = Enum.AnimationPriority.Action4
    while animTrack.Length == 0 do
        print("Loading... Time Taken So Far:")
        task.wait(0.01)

    end
    animTrack:Play()
    character.HumanoidRootPart.CFrame = game.Workspace.mainbacon.LowerTorso.CFrame
    animTrack:AdjustSpeed(0.4)
    task.wait(animTrack.Length / 0.4 - 0.05)
    local speed = animTrack.Speed
    print("wha")
    animTrack:AdjustSpeed(0)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    task.wait(3)
    
    animTrack:AdjustSpeed(1000)
    --[[animation:Destroy()
    animTrack:Destroy()]]
    
    task.wait(3)
    
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    
    
    
end)``` most of this code is just commented code that i don't use anymore or random things i used to try to fix this
reef roost
#
local event = game.ReplicatedStorage.WhereItAllBegan
local character = game.Workspace.mainbacon
local event3 = game.ReplicatedStorage.BombEvent


local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")


event.Event:Connect(function(plr)
    
    local animation = Instance.new("Animation")
    animation.AnimationId = "rbxassetid://74795693307326"
    local animTrack = animator:LoadAnimation(animation)
    animTrack.Priority = Enum.AnimationPriority.Action4
    while animTrack.Length == 0 do
        print("Loading... Time Taken So Far:")
        task.wait(0.01)

    end
    animTrack:Play()
    character.HumanoidRootPart.CFrame = game.Workspace.mainbacon.LowerTorso.CFrame
    animTrack:AdjustSpeed(0.4)
    task.wait(animTrack.Length / 0.4 - 0.05)
    local speed = animTrack.Speed
    print("wha")
    animTrack:AdjustSpeed(0)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    task.wait(3)
    
    animTrack:AdjustSpeed(1000)
    --[[animation:Destroy()
    animTrack:Destroy()]]
    
    task.wait(3)
    
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    
    
    
end)
#

@magic patio what exactly is the issue? i don't understand

reef roost
#

the thing at 10s?

magic patio
#

but not the full problem

#

at 13 s

#

u can see it returns to its original spot

reef roost
#

for me the vid crashes at 11s

magic patio
#

cuz thats what happens after

magic patio
reef roost
#

oh wait it loaded now

magic patio
reef roost
#

its teleporting between tents?

magic patio
#

hang on ill explain

#

so after an anim plays

#

it will return to it's original spot

#

kinda like it tweens

#

im trying to make it teleport to a different spot

reef roost
#

i see you're setting the CFrame everywhere

#

theres multiple issues with that

#
  1. CFrame can't normally be set, you change it using .Position
magic patio
reef roost
#
  1. CFrame also holds orientation, so it will also copy the rotation
magic patio
#

ok i see

#

well heres whats going on

#

the character no longer snaps back to its original position

reef roost
#

so.. its good or am i missing something?

magic patio
#

i may have to check some things

reef roost
#

could you show an example video?

#

@magic patio keep the code after the = with CFrame because its defining where it has to go not changing it

reef roost
magic patio
#

ok current code ```local event = game.ReplicatedStorage.WhereItAllBegan
local character = game.Workspace.mainbacon
local event3 = game.ReplicatedStorage.BombEvent

local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local event2 = game.ReplicatedStorage.TalkEvent
local event4 = game.ReplicatedStorage.ChestEvent
event.Event:Connect(function(plr)
for i, v in pairs(character:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") then
if v.Name ~= "HumanoidRootPart" then
print("cycling")
v.Transparency =0
end

    end
    if v:FindFirstChild("Handle") then

        v.Handle.Transparency =0
        
    end
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://74795693307326"
local animTrack = animator:LoadAnimation(animation)
animTrack.Priority = Enum.AnimationPriority.Action4
while animTrack.Length == 0 do
    print("Loading... Time Taken So Far:")
    task.wait(0.01)

end
animTrack:Play()
character.HumanoidRootPart.CFrame = game.Workspace.mainbacon.LowerTorso.CFrame
animTrack:AdjustSpeed(0.4)
task.wait(animTrack.Length / 0.4 - 0.05)
local speed = animTrack.Speed
print("wha")
animTrack:AdjustSpeed(0)
--character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
task.wait(3)

animTrack:AdjustSpeed(1000)
--[[animation:Destroy()
animTrack:Destroy()]]

task.wait(3)

print(character.HumanoidRootPart.CFrame)
--task.wait(2)
character.HumanoidRootPart.Position= game.Workspace.mainman.HumanoidRootPart.CFrame.Position
print(character.HumanoidRootPart.Position)

end)```

#

@reef roost

#

and ill record something

reef roost
#

could you do something for me?

#

when you make it a code block

#

please type lua after the first 3 dots as so: ``lua

#

but with 3 dots instead of 2

magic patio
#

lua

reef roost
#

it gives color based on lua code

#

easier to review

magic patio
#

``lua`

#

hm

#
local character = game.Workspace.mainbacon
local event3 = game.ReplicatedStorage.BombEvent


local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local event2 = game.ReplicatedStorage.TalkEvent
local event4 = game.ReplicatedStorage.ChestEvent
event.Event:Connect(function(plr)
    for i, v in pairs(character:GetChildren()) do
        if v:IsA("Part") or v:IsA("MeshPart") then
            if v.Name ~= "HumanoidRootPart" then
                print("cycling")
                v.Transparency =0
            end
            
            
        end
        if v:FindFirstChild("Handle") then

            v.Handle.Transparency =0
            
        end
    end
    local animation = Instance.new("Animation")
    animation.AnimationId = "rbxassetid://74795693307326"
    local animTrack = animator:LoadAnimation(animation)
    animTrack.Priority = Enum.AnimationPriority.Action4
    while animTrack.Length == 0 do
        print("Loading... Time Taken So Far:")
        task.wait(0.01)

    end
    animTrack:Play()
    character.HumanoidRootPart.CFrame = game.Workspace.mainbacon.LowerTorso.CFrame
    animTrack:AdjustSpeed(0.4)
    task.wait(animTrack.Length / 0.4 - 0.05)
    local speed = animTrack.Speed
    print("wha")
    animTrack:AdjustSpeed(0)
    --character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    task.wait(3)
    
    animTrack:AdjustSpeed(1000)
    --[[animation:Destroy()
    animTrack:Destroy()]]
    
    task.wait(3)
    
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.Position= game.Workspace.mainman.HumanoidRootPart.CFrame.Position
    print(character.HumanoidRootPart.Position)
    

    
    
end)```
reef roost
#
local lua = false
local lua = true
magic patio
#
local event = game.ReplicatedStorage.WhereItAllBegan
local character = game.Workspace.mainbacon
local event3 = game.ReplicatedStorage.BombEvent


local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local event2 = game.ReplicatedStorage.TalkEvent
local event4 = game.ReplicatedStorage.ChestEvent
event.Event:Connect(function(plr)
    for i, v in pairs(character:GetChildren()) do
        if v:IsA("Part") or v:IsA("MeshPart") then
            if v.Name ~= "HumanoidRootPart" then
                print("cycling")
                v.Transparency =0
            end
            
            
        end
        if v:FindFirstChild("Handle") then

            v.Handle.Transparency =0
            
        end
    end
    local animation = Instance.new("Animation")
    animation.AnimationId = "rbxassetid://74795693307326"
    local animTrack = animator:LoadAnimation(animation)
    animTrack.Priority = Enum.AnimationPriority.Action4
    while animTrack.Length == 0 do
        print("Loading... Time Taken So Far:")
        task.wait(0.01)

    end
    animTrack:Play()
    character.HumanoidRootPart.CFrame = game.Workspace.mainbacon.LowerTorso.CFrame
    animTrack:AdjustSpeed(0.4)
    task.wait(animTrack.Length / 0.4 - 0.05)
    local speed = animTrack.Speed
    print("wha")
    animTrack:AdjustSpeed(0)
    --character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    task.wait(3)
    
    animTrack:AdjustSpeed(1000)
    --[[animation:Destroy()
    animTrack:Destroy()]]
    
    task.wait(3)
    
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.Position= game.Workspace.mainman.HumanoidRootPart.CFrame.Position
    print(character.HumanoidRootPart.Position)
    
    
    
end)```
#

yaaaay

reef roost
#

yes like that

magic patio
#

i had to put an enter after lua

reef roost
#

alr what was the issue again?

magic patio
#

at 0:19

#

the bacon goes the wrong way

#

it seems

reef roost
#

i see..

magic patio
#

the place its meant to go is uh the other way

reef roost
#

try reversing the vector3?

magic patio
#

uh i dont think i got a vector3 anywhere in here

reef roost
magic patio
tiny matrixBOT
#

studio** You are now Level 14! **studio

reef roost
#

you could do...

#
Vector3.new(CFrame.Position.X,-CFrame.Position.Y,CFrame.Position.Z)
#

and then

reef roost
#

add a - before which one you want to negatate

#

currently making Y negative in the line

magic patio
#

oh

reef roost
#

but this probably won't work, but if it does its great

#

otherwise you could manually set CFrame.Position.Y to something else

magic patio
#

LOL

#

LOOK AT THIS

reef roost
#

?

magic patio
#

at the end its uh weird

#

i think its cuz

reef roost
#

yeah kinda expected that..

#

let me explain

magic patio
#

humanoidrootpart is 0
somehow it becomes like 5
so if we negate it its kinda -5

reef roost
#

you already explain it yourself, great

magic patio
#

thats my theory anyway

#

now thats so weird

reef roost
#

you could manually change the value to lets say.. 3

#

until you get the position right

magic patio
reef roost
#

is it working?

magic patio
#

but theres this really funny thing going on

#

im setting the humanoidrootpart's cframe

#

BUT THE HUMANOIDROOTPART DOESN'T MOVE??

#

only the character moves

#

this is ridiculous

reef roost
#

umm did you remember what i said?

#

you cannot set the CFrame of something, its just used to get positions

reef roost
#

its like an info block

magic patio
#

the humanoidrootpart is just uh

#

its just stuck

reef roost
#

without CFrame

magic patio
#
character.HumanoidRootPart.Position= Vector3.new(game.Workspace.Placed.CFrame.Position.X,game.Workspace.Placed.CFrame.Position.Y - 2,game.Workspace.Placed.CFrame.Position.Z - 25)```
#

im literally setting position of the humanoidroot part

#

roblox engine is so weird

reef roost
#

i recommend you do :WaitForChild("HumanoidRootPart").Position UNLESS you already know its loaded

magic patio
reef roost
tiny matrixBOT
#

studio** You are now Level 7! **studio

magic patio
#

im searching it up

#

ohhhhhh

reef roost
#

click F9 to see logs

#

check for errors

magic patio
#

i think its a client thing

#

i saw this post

reef roost
magic patio
reef roost
magic patio
#

i wanted it to only play on the localside

magic patio
#

cuz u cant use :getanimationsplaying or something in serverscripts

#

roblox failing me rn 😭

reef roost
#

i see

#

you could always use task.wait() functions

#

but then

#

if your animation lags, its slow

magic patio
#

so new players get a cutscene when playing for first time

reef roost
#

1 sec be back in 2 min

magic patio
reef roost
#

back

magic patio
#

alr

#

welp im stumped

#

i cant use localscript and yet i must

#

like running into a lava pit, turning around and running into another

#

😭

reef roost
#

ok ok wait

#

you can't change the position rn, but you could before?

magic patio
#

so uh from a previous post

#

turns out

#

during an animation the humanoidrootpart doesn't follow the character

#

which is a roblox thing

#

not a big deal

reef roost
#

question.

magic patio
#

but...

reef roost
#

are the body parts anchored?

magic patio
reef roost
#

ok good then im not really sure anymore..

magic patio
#

if they are anchored i cant play animations

#

welp

#

i give up

reef roost
#

wait

#

can you show a vid so i can better see the issue? cuz rn ur just saying "humanoidrootpart no move"

reef roost
#

just seems like a floating bacon

#

are you sure you have the position put in correctly?

magic patio
#

the weird thing is that the hrp is just there

#

in the tent

reef roost
#

normally the body follows the root

magic patio
#

i use position to move the hrp, the body moves but the HRP doesn't MOVE...

#

what kinda logic is this

#

i think theres something locking the hrp in place

#

so the body moves but the hrp is stuck

reef roost
#

and you're viewing ingame right?

magic patio
reef roost
#

you didn't activate "show server"

#

alr

magic patio
#

the server is not affected

reef roost
#

yeah i know, that would of explained the issue

magic patio
reef roost
magic patio
#

yeah i think i should give up

#

i don't think this is a common problem

reef roost
#

do you have another other scripts in the game?

magic patio
#

nothing

#

only that one script

reef roost
#

did it work before you changed it to vector.new(bla bla bla)?

magic patio
reef roost
#

hmm i see, so the root was already acting strange?

reef roost
#

hmm...

#

let me try making a tool that changes my root position rq

#

hmmm

#

when i used a local script to move my root

#

it worked

magic patio
reef roost
#

your code is defining the position wrong, could you send another copy?

#

by the way, i noticed my body did NOT follow my root...

magic patio
#

ill send the code

#
local event = game.ReplicatedStorage.WhereItAllBegan
local character = game.Workspace.mainbacon
local event3 = game.ReplicatedStorage.BombEvent


local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local event2 = game.ReplicatedStorage.TalkEvent
local event4 = game.ReplicatedStorage.ChestEvent
event.Event:Connect(function(plr)
    for i, v in pairs(character:GetChildren()) do
        if v:IsA("Part") or v:IsA("MeshPart") then
            if v.Name ~= "HumanoidRootPart" then
                print("cycling")
                v.Transparency =0
            end
            
            
        end
        if v:FindFirstChild("Handle") then

            v.Handle.Transparency =0
            
        end
    end
    local animation = Instance.new("Animation")
    animation.AnimationId = "rbxassetid://74795693307326"
    local animTrack = animator:LoadAnimation(animation)
    animTrack.Priority = Enum.AnimationPriority.Action4
    while animTrack.Length == 0 do
        print("Loading... Time Taken So Far:")
        task.wait(0.01)

    end
    animTrack:Play()
    character.HumanoidRootPart.CFrame = game.Workspace.mainbacon.LowerTorso.CFrame
    animTrack:AdjustSpeed(0.4)
    task.wait(animTrack.Length / 0.4 - 0.05)
    local speed = animTrack.Speed
    print("wha")
    animTrack:AdjustSpeed(0)
    --character.HumanoidRootPart.CFrame = game.Workspace.mainman.HumanoidRootPart.CFrame
    task.wait(3)
    
    animTrack:AdjustSpeed(1000)
    --[[animation:Destroy()
    animTrack:Destroy()]]
    
    task.wait(3)
    
    print(character.HumanoidRootPart.CFrame)
    --task.wait(2)
    character.HumanoidRootPart.Position= Vector3.new(game.Workspace.Placed.CFrame.Position.X,game.Workspace.Placed.CFrame.Position.Y - 2,game.Workspace.Placed.CFrame.Position.Z - 25)
    print(character.HumanoidRootPart.Position)
    end)```
reef roost
#

im not 100% sure what the issue is, but this is how i moved my root using my tool

#

i hope this gives atleast some info, but i gtg now its very late

#

@magic patio can i ask you 1 thing before i go tho?

reef roost
#

how did you get the scripter role?

magic patio
reef roost
#

just.. automatically?

magic patio
#

my ranker was nice

#

he said i had room to improve but

reef roost
#

wait wait ranker?

magic patio
reef roost
#

im just asking how i myself could get a role like that

magic patio
reef roost
#

do i like ask someone to give it?

magic patio
#

and wait for a ranker to rank u

#

if ur good enough, which u probably are

reef roost
#

ohhh i see, never knew this existed lol

#

so theres no quiz u just send ur work?

magic patio
#

simple as that

reef roost
#

oh

#

well thx for the info

#

i gtg now tho

magic patio
magic patio
reef roost
#

i hope u find a solution to ur bug

#

bye