local Player = game.Players.LocalPlayer
local tool = script.Parent
local Character = tool.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:FindFirstChild("Animator")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6350259222"
local AnimationTrack = Animator:LoadAniamtion(Anim)
local Anim2 = Instance.new("Animation")
Anim2.AnimationId = "rbxassetid://6364334315"
local AnimationTrack = Animator:LoadAnimation(Anim2)
local RS = game:GetService("ReplicatedStorage")
local Strengh = RS.RemoteEvents.Strengh
local db = false
--Animation
tool.Equipped:Connect(function()
Anim:Play()
Anim.Priority = Enum.AnimationPriority.Idle
Humanoid.UseJumpPower = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
end)
tool.Activated:Connect(function()
if db == false then
db = true
Anim2:Play()
Anim2.Priority = Enum.AnimationPriority.Action
Strengh:FireServer()
wait(2)
db = false
end
end)
tool.Unequipped:Connect(function()
Anim:Stop()
Anim2:Stop()
Anim:Destroy()
Anim2:Destroy()
Humanoid.UseJumpPower = true
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end)
local Tool = script.Parent
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") then
local Humanoid = Character.Humanoid
local Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6350259222" --Animation 1
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end
end
Tool.Equipped:Connect(Equipped)
local Debounce = true
local Animator = nil
local Humanoid = nil
local function Activated()
if Debounce == true then
Debounce = false
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") then
Humanoid = Character.Humanoid
Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6364334315" --Animation 2
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StrengthEvent = ReplicatedStorage.RemoteEvents.Strength
StrengthEvent:FireServer()
wait(2)
Debounce = true
end
end
Tool.Activated:Connect(Activated)
local function Unequipped()
if Animator then
local PlayingAnimationTracks = Animator:GetPlayingAnimationTracks()
for _, PlayingAnimationTrack in pairs(PlayingAnimationTracks) do
PlayingAnimationTrack:Stop()
end
end
if Humanoid then
Humanoid.UseJumpPower = true
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end
Instead of making the script local, make it server sided.
You can change the animation priority in the build-in animation editor plugin.
Please tell me if there are any issues.
Edit: You should not change anything in this script, if correct; everything should work for your setup.
I think it should be changed because when I tried to use the code you gave me, it did not give me the error from before but the animations were not reproduced as they should:
local Player = game.Players.LocalPlayer
local tool = script.Parent
local Character = tool.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:FindFirstChild("Animator")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6350259222"
local AnimationTrack = Animator:LoadAniamtion(Anim)
local Anim2 = Instance.new("Animation")
Anim2.AnimationId = "rbxassetid://6364334315"
local AnimationTrack = Animator:LoadAnimation(Anim2)
local RS = game:GetService("ReplicatedStorage")
local Strengh = RS.RemoteEvents.Strengh
local db = false
--Animation
tool.Equipped:Connect(function()
Anim:Play()
Anim.Priority = Enum.AnimationPriority.Idle
Humanoid.UseJumpPower = true
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
end)
tool.Activated:Connect(function()
if db == false then
db = true
Anim2:Play()
Anim2.Priority = Enum.AnimationPriority.Action
Strengh:FireServer()
wait(2)
db = false
end
end)
tool.Unequipped:Connect(function()
Anim:Stop()
Anim2:Stop()
Anim:Destroy()
Anim2:Destroy()
Humanoid.UseJumpPower = true
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end)
local Tool = script.Parent
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") then
local Humanoid = Character.Humanoid
local Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6350259222" --Animation 1
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end
end
Tool.Equipped:Connect(Equipped)
local Debounce = true
local Animator = nil
local Humanoid = nil
local function Activated()
if Debounce == true then
Debounce = false
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") then
Humanoid = Character.Humanoid
Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6364334315" --Animation 2
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
end
local Players = game:GetService("Players")
local Player = Players:GetPlayerFromCharacter(Character)
Player.leaderstats.Strength.Value += 1
wait(2)
Debounce = true
end
end
Tool.Activated:Connect(Activated)
local function Unequipped()
if Animator then
local PlayingAnimationTracks = Animator:GetPlayingAnimationTracks()
for _, PlayingAnimationTrack in pairs(PlayingAnimationTracks) do
PlayingAnimationTrack:Stop()
end
end
if Humanoid then
Humanoid.UseJumpPower = true
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end
There is no such ‘‘greater security’’ when talking about animations. In fact, it’s easier to just set the animation priority inside of the build-in plugin rather than setting them inside of scripts. And why would you set them both? Only one is necessary.