local players = game.Players.LocalPlayer
local anim1 = script.Parent.Animation
local anim2 = script.Parent.FireAnimation
local anim = script.Parent.Rest
local camera = game.Workspace.CurrentCamera
local track
local track2
local trackA
local UIS = game:GetService("UserInputService")
local CanFire = false
script.Parent.Equipped:Connect(function()
track = players.Character.Humanoid:LoadAnimation(anim1)
track:play()
end)
script.Parent.Unequipped:Connect(function()
trackA = players.Character.Humanoid:LoadAnimation(anim)
track:stop()
trackA:stop()
end)
local debouce = false
script.Parent.Activated:Connect(function()
if debouce == false then
debouce = true
track2 = players.Character.Humanoid:LoadAnimation(anim2)
track2:play()
camera.CFrame = camera.CFrame * CFrame.Angles(.005,math.rad(.5),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(.0015,math.rad(.8),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(.002,math.rad(.5),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(-.0015,math.rad(0),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(-.005,math.rad(0),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(-.002,math.rad(0),0)
debouce = false
end
end)
local Temp = false
UIS.InputBegan:Connect(function(key)
if players.Character:FindFirstChild("M911") then
if key.KeyCode == Enum.KeyCode.E then
if Temp == false then
Temp = true
print("K")
trackA = players.Character.Humanoid:LoadAnimation(anim)
trackA:play()
elseif Temp == true then
Temp = false
trackA:stop()
end
end
end
end)
#Animation still plays even after unquippeded
1 messages · Page 1 of 1 (latest)
any errors?
No theres no errors
wait a minute what's the "script.Parent"
ok so where is this tool?
Its in the character
does it get cloned there from starterPack?
Yeah
ok so what you're actually changing isn't the tool in workspace you're changing the tool that gets cloned to workspace. and the solution would be get the tool from workspace instead inside the character
so something like this:
local player = game.Players.LocalPlayer
local characterModel = workspace:WaitForChild(player.Name)
local tool = characterModel:WaitForChild("M911")
@slender badger try this
Still didn't work?
any errors?
Theres no errors but now when I click e for any other tool, it also plays the animation. instead of just playing it for this specific tool
** You are now Level 8! **
ok send code
local players = game.Players.LocalPlayer
local anim1 = script.Parent.Animation
local anim2 = script.Parent.FireAnimation
local anim = script.Parent.Rest
local camera = game.Workspace.CurrentCamera
local characterModel = workspace:WaitForChild(players.Name)
local tool = characterModel:WaitForChild("M911")
local track
local track2
local trackA
local UIS = game:GetService("UserInputService")
local CanFire = false
script.Parent.Equipped:Connect(function()
track = players.Character.Humanoid:LoadAnimation(anim1)
track:play()
end)
script.Parent.Unequipped:Connect(function()
trackA = players.Character.Humanoid:LoadAnimation(anim)
track:stop()
trackA:stop()
end)
local debouce = false
script.Parent.Activated:Connect(function()
if debouce == false then
debouce = true
track2 = players.Character.Humanoid:LoadAnimation(anim2)
track2:play()
camera.CFrame = camera.CFrame * CFrame.Angles(.005,math.rad(.5),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(.0015,math.rad(.8),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(.002,math.rad(.5),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(-.0015,math.rad(0),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(-.005,math.rad(0),0)
wait(.01)
camera.CFrame = camera.CFrame * CFrame.Angles(-.002,math.rad(0),0)
debouce = false
end
end)
local Temp = false
UIS.InputBegan:Connect(function(key)
if tool then
if key.KeyCode == Enum.KeyCode.E then
if Temp == false then
Temp = true
print("K")
trackA = players.Character.Humanoid:LoadAnimation(anim)
trackA:play()
elseif Temp == true then
Temp = false
trackA:stop()
end
end
end
end)
bro you didn't use the tool variable
you said script.Parent.Equipped instead of tool.Equipped
Oh
so everytime you say script.Parent replace it with tool variable instead
@slender badger so did it work?
theres an error
"Infinite yield possible on 'Workspace.Nullendex:WaitForChild("M911")' "
oh ok so where is the tool cloned in the character when you run the game send a screenshot of the explorer
oh ok so the tool isn't always inside the character so you should replace WaitForChild on the tool variable to FindFirstChild instead and then say if tool then
local tool = characterModel:FindFirstChild("M911")
if tool then
-- rest of ur code that uses tool variable
end
@slender badger
Alright I'll try it
No errors but the animation is still playing even when unequipped
@slender badger try saying :Play() and :Stop() instead of :play() and :stop()
"Infinite yield possible on 'Workspace.Nullendex:WaitForChild("M911")'"
I did findfirstchild, and the animation wouldn't even play? so I did waitforchild and findfirstchild
well WaitForChild will just throw an infinite yield error because the tool isn't always in the character
what is the problem here?
Animation plays even after the tool is unequipped
u dont end the animation? , maybe
he uses :Stop() to do that
pretty sure
Still would work
well it isn't so I am guessing one of his debounce if conditions isn't triggering which is making it not reach the :Stop()
I dont think you could stop an animation from diff track.
@slender badger , just make it global
because ur creating a new track of an animation which hasnt been played and you stopped it
which doesnt make anysense, however if u make the animation track becomes global. It'll recognize the animation track and stop it
even if he doesn't make it global it should still work:
The stopping thing wont work
it just plays
oh my fudge
My bad
he indeed made it global
I dont see anything wrong beside stop and play
my bad chat
:stop and :play
I told him to change that here:
idrk if he did
@slender badger did you do this
Yes
and still nothing?
@slender badger ok so I was wrong about the tool thing just leave it as script.Parent my bad
alr
@slender badger so does it work now?
No it still isn't working
Cause you're loading the animation twice
youre trying to stop a completely different thing
make a global variable that loads the animation and manipulate only it
local track = players.Character.Humanoid:LoadAnimation(anim1)
function onEquip()
track:Play()
end
function unEquip()
track:Stop()
end
he didn't tho he's loading different animations