#Animation freezing and wont unfreeze upon dropping tool
1 messages · Page 1 of 1 (latest)
** You are now Level 7! **
hmm
well first thing there is a memory leak, you wouldnt want to load a new animation on every equip & unequip
i suggest you load it outside kf these events and then play/stop as needed
how would i do that?
instead of defining the track when the tool is equipped or unequipped, i suggest you define it directly after it's declared
can you copy the code and send it in a codeblock here
@tepid bloom
yeah this too
oh ight
i use moon animator so idk if thatll effect
copy your code
& paste it here but with lua at the top and at the bottom
not that
`
`
`
at top
and `
`
`
at bottom
no spaces or anything
alr 1 sec mb took a while
`local player = game.Players.LocalPlayer
local holdAnim = script.HoldAnim
local unequip = script["Unequip Anim"]
local track
local track2
local bool = false
script.Parent.Equipped:Connect(function()
bool = not bool
if bool == true then
track = player.Character.Humanoid:LoadAnimation(holdAnim)
track:Play()
track:GetMarkerReachedSignal("End"):Connect(function()
track:AdjustSpeed(0)
end)
end
end)
script.Parent.Unequipped:Connect(function()
track:Stop()
track2 = player.Character.Humanoid:LoadAnimation(unequip)
track2:Play()
end)
script.Parent.ChildRemoved:Connect(function()
track2:Play()
track:Stop()
end)`
like this i meant
oh
local holdAnim = script.HoldAnim
local unequip = script["Unequip Anim"]
local track
local track2
local bool = false
script.Parent.Equipped:Connect(function()
bool = not bool
if bool == true then
track = player.Character.Humanoid:LoadAnimation(holdAnim)
track:Play()
track:GetMarkerReachedSignal("End"):Connect(function()
track:AdjustSpeed(0)
end)
end
end)
script.Parent.Unequipped:Connect(function()
track:Stop()
track2 = player.Character.Humanoid:LoadAnimation(unequip)
track2:Play()
end)
script.Parent.ChildRemoved:Connect(function()
track2:Play()
track:Stop()
end)```
how does it help btw?
readability
fair
are your animations looped?
i mean if i do play without freeze it ends so no
like if i do track:play it doesnt loop
ok
one sec
wait
wrong one
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
-- Animations
local HoldAnimation = script.HoldAnim
local AnimationTrack1 = Animator:LoadAnimation(script.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
script.Parent.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Connect(function()
AnimationTrack1:Stop()
end)
end
end)
script.Parent.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
script.Parent.ChildRemoved:Connect(function()
UnequipAnimation:Play()
AnimationTrack1:Stop()
end)
@tepid bloom
issue now is
when i equip, the animation plays and then resets like
ohh
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
-- Animations
local HoldAnimation = script.HoldAnim
local AnimationTrack1 = Animator:LoadAnimation(script.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
script.Parent.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Connect(function()
AnimationTrack1:AdjustSpeed(0)
end)
end
end)
script.Parent.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
script.Parent.ChildRemoved:Connect(function()
UnequipAnimation:Play()
AnimationTrack1:Stop()
end)
now it has the same old bug but also another 😭
oh wait
is it joeover
wait
what if instead of stop or adjust speed
u use pause
would that work
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
-- Animations
local HoldAnimation = script.HoldAnim
local AnimationTrack1 = Animator:LoadAnimation(script.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
script.Parent.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack:AdjustSpeed(1)
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Connect(function()
AnimationTrack1:AdjustSpeed(0)
end)
end
end)
script.Parent.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
script.Parent.ChildRemoved:Connect(function()
UnequipAnimation:Play()
AnimationTrack1:Stop()
end)
try this
same thing
19:57:01.432 Workspace.CYBORG1230987654.Torch.equip:22: attempt to index nil with 'AdjustSpeed' - Client - equip:22
doesnt play anims
wrong variable reference
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
-- Animations
local HoldAnimation = script.HoldAnim
local AnimationTrack1 = Animator:LoadAnimation(script.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
script.Parent.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack1:AdjustSpeed(1)
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Connect(function()
AnimationTrack1:AdjustSpeed(0)
end)
end
end)
script.Parent.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
script.Parent.ChildRemoved:Connect(function()
UnequipAnimation:Play()
AnimationTrack1:Stop()
end)
moment of truth
ok @signal swallow now it has the same problem that i started with 😭
show a video
ok wait
2 bugs
so the issue is, it doesnt play on the second time you equip it?
if u equip, unequip, re-equip then anim doesnt play 😭
also if u drop the object like at the end
it sticks u in that anim
ok wait
script parent child removed is supposed to stop the animations when the tool gets removed?
idek man 😭
one min
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Tool = script.Parent
-- Animations
local HoldAnimation = script.HoldAnim
local AnimationTrack1: AnimationTrack = Animator:LoadAnimation(script.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
Tool.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Once(function()
AnimationTrack1:Stop()
end)
end
end)
Tool.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
Tool.AncestryChanged:Connect(function(_, Parent)
if Parent ~= Player.Backpack and Parent ~= Character then
-- Tool dropped
AnimationTrack1:Stop()
UnequipAnimation:Play()
end
end)
20:08:22.476 HoldAnim is not a valid member of LocalScript "Workspace.CYBORG1230987654.Torch.Torch Activate" - Client - Torch Activate:8
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Tool = script.Parent
-- Animations
local HoldAnimation = script.HoldAnim
local AnimationTrack1: AnimationTrack = Animator:LoadAnimation(script.Parent.equip.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script.Parent.equip["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
Tool.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Once(function()
AnimationTrack1:Stop()
end)
end
end)
Tool.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
Tool.AncestryChanged:Connect(function(_, Parent)
if Parent ~= Player.Backpack and Parent ~= Character then
-- Tool dropped
AnimationTrack1:Stop()
UnequipAnimation:Play()
end
end)
20:13:06.865 HoldAnim is not a valid member of LocalScript "Workspace.CYBORG1230987654.Torch.Torch Activate" - Client - Torch Activate:8
😭
new script
yeah same error
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Tool = script.Parent
-- Animations
local HoldAnimation = script.Parent.equip.HoldAnim
local AnimationTrack1: AnimationTrack = Animator:LoadAnimation(script.Parent.equip.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script.Parent.equip["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
Tool.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Once(function()
AnimationTrack1:Stop()
end)
end
end)
Tool.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
Tool.AncestryChanged:Connect(function(_, Parent)
if Parent ~= Player.Backpack and Parent ~= Character then
-- Tool dropped
AnimationTrack1:Stop()
UnequipAnimation:Play()
end
end)
same
error
😭
local HoldAnimation = script.Parent.equip.HoldAnim
this is line 8
idfk whats going wrong
are you sure your pasting the new script in
yes
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Tool = script.Parent
-- Animations
local HoldAnimation = script.Parent.equip.HoldAnim
local AnimationTrack1: AnimationTrack = Animator:LoadAnimation(script.Parent.equip.HoldAnim)
local UnequipAnimation = Animator:LoadAnimation(script.Parent.equip["Unequip Anim"])
local Boolean = false
Player.CharacterAdded:Connect(function(NewCharacter)
Character = NewCharacter
Humanoid = NewCharacter:WaitForChild("Humanoid")
Animator = Humanoid:WaitForChild("Animator")
end)
Tool.Equipped:Connect(function()
Boolean = not Boolean
if Boolean then
AnimationTrack1:Play()
AnimationTrack1:GetMarkerReachedSignal("End"):Once(function()
AnimationTrack1:Stop()
end)
end
end)
Tool.Unequipped:Connect(function()
AnimationTrack1:Stop()
UnequipAnimation:Play()
end)
Tool.AncestryChanged:Connect(function(_, Parent)
if Parent ~= Player.Backpack and Parent ~= Character then
-- Tool dropped
AnimationTrack1:Stop()
UnequipAnimation:Play()
end
end)```
this is it
one min
alr
mind if im back in like 20 min
allg
just tell me, am i cooked
this is solvable but ill be back in some time
hmm alright
ping me when ur back with a possible solution
ok
i might have to help tomorrow, my brain isnt braining
fair mine either 😭
uhm
try equipping the tool for the third time
Boolean = not Boolean goes from false to true (equip), true to false (second equip) and false to true (third equip)
when i drop it, im still stuck in the animation
i can fix taht js fine but
the drop bug 😭
is the script inside of the tool?
yh
when dropping is the tool destroyed or dropped on the floor in workspace?
as in backspace
ok test my theory
does ancestry changed print anything
wait is it a localscrip tor serverscript
localscript*
localscripts dont run in workspace
so that'd be your issue when dropping it
iirc
usually when it comes to handling tools, i tend to handle it using a script external from the tool itself, since when it's destroyed and/or moved to a place where the code wouldnt run that defeats the purpose of handling cleanup
this is where module scripts tend to come in handy
as i can attach the module to the tool and clean it up when required
💪
i used ancestry changed; destroyed does not fire when the parent of a tool is changed (which here it's going from the character model to directly under workspace)
they run under tools under character models
ik
when dropped it goes to workspace
afaik
(standalone, mb for not clarifying)
a script with runcontext client would be better for this then
aye
learnt something new today, the actual use of runcontext lmao
never really needed to explore it so not actually found a use case for it cause of the way i manage my codebase
true
still for destruction cleanup i'd manage the tool externally or use something like Trove, Maid or Janitor
and attach it to the tool itself
😋
idk what that is, but if its a library, i dont think we need to go that far
And tracking objects n stuff
This is sorta off topic so mb
its fine im cooked anyways
ts pmo 😢
ggwp
i give up lol, lmk if yall find a solution but until then ill just use the default anim so i can continue scripting other stuff
send me a copy place file
ill work on it tmrw
dwdw