You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve?
An animation that stops whenever you equip another tool!
- What is the issue?
The issue is when I equip another tool the animation won’t stop, I already have a script for the animation that whenever you move the animations stops and when you stand still it plays, but if you stand still and equip another tool the animation stays there and like doesn’t stop or anything!
- What solutions have you tried so far?
Finding a solution!
game.ReplicatedStorage.Shop.Equip.OnServerInvoke = function(Player,_CItem)
local Item = Shop[_CItem.Type][_CItem.Name]
local ItemConfig = require(Item.ToolProperties)
if game.ServerStorage.PlayerData[Player.Name].Inventory.Equipped[_CItem.Type]:FindFirstChild(_CItem.Name) == nil then
local idleTrack = nil
for i2, v2 in pairs(Player.Character:GetChildren()) do
if v2:IsA("Tool") then
idleTrack = Player.Character.Humanoid:LoadAnimation(v2.IdleAnimation.idle)
idleTrack:Stop()
end
end
for i,v in pairs(ItemConfig.Scripts) do
v.Disabled = false
end
Player.StarterGear:ClearAllChildren()
Player.Backpack:ClearAllChildren()
game.ServerStorage.PlayerData[Player.Name].Inventory.Equipped[_CItem.Type]:ClearAllChildren()
local oldTool = Player.Character:FindFirstChildOfClass("Tool")
if oldTool ~= nil then
if oldTool:FindFirstChildOfClass("LocalScript") or oldTool:FindFirstChildOfClass("Script") then
oldTool:Destroy()
end
end
local StarterGearIteam = Item:Clone()
local BackpackIteam = Item:Clone()
StarterGearIteam.Parent = Player.StarterGear
BackpackIteam.Parent = Player.Backpack
for i,v in pairs(ItemConfig.Scripts) do
v.Disabled = true
end
local ServerItem = Item:Clone()
ServerItem.Parent = game.ServerStorage.PlayerData[Player.Name].Inventory.Equipped[_CItem.Type]
StarterGearIteam:FindFirstChild("ToolProperties"):Destroy()
BackpackIteam:FindFirstChild("ToolProperties"):Destroy()
return true
else
return false
end
end
Thank you in advance!