It gives me the strength but however it does not play the animation...
local tool = script.Parent local plr = game.Players.LocalPlayer local Character = plr.Character or plr.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") local Anim = Instance.new("Animation") Anim.AnimationId = "rbxassetid://4139476411" local PlayAnim = Humanoid:LoadAnimation(Anim) tool.Activated:Connect(function() PlayAnim:Play() wait(.7) plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value + 1 PlayAnim:Stop() end)
Okay, so I had to rewrite your code as I noticed a big problem with your script. You're using LocalPlayer which only works in local scripts, but changing the leaderstats on a local script will only show for you and not everyone else.
I fixed this by making the script a server (normal) script and getting the player that equipped the tool instead of the LocalPlayer. I also added a debounce to prevent spam.
Here's the code:
local Players = game:GetService("Players") local tool = script.Parent local plr local Character local Humanoid local Anim = Instance.new("Animation") Anim.AnimationId = "rbxassetid://4139476411" local PlayAnim local debounce = false tool.Activated:Connect(function() if debounce == true then return -- Function will stop here if debounce is true to prevent spam. end debounce = true if PlayAnim ~= nil then -- Checks if animation loaded to prevent errors PlayAnim:Play() wait(.7) plr.leaderstats.Strength.Value = plr.leaderstats.Strength.Value + 1 PlayAnim:Stop() end debounce = false -- After the animation plays, debounce will be false so tool can be used again. end) tool.Equipped:Connect(function() plr = Players:GetPlayerFromCharacter(script.Parent.Parent) -- Gets the player that equipped the item if plr ~= nil then Character = plr.Character Humanoid = Character:WaitForChild("Humanoid") PlayAnim = Humanoid:LoadAnimation(Anim) end end)
Hope this helped! Sorry for making all this complicated. If you have any questions, just comment!