Let’s say it’s just that sometimes I forget to set them in the built-in plugin and sometimes I do it to do it
You better not forget those things. If you do it more often, you don’t forget things like that. And you could always edit your animation, even after exporting it.
There is another problem and it is that sometimes when the animation is played, the character stands up and that is something that I also want to solve
Instead of making the humanoid have 0 jumppower and walksspeed, you could anchor the PrimaryPart of the character (HumanoidRootPart).
It works well it just comes up out of nowhere.
Could you explain to me what works and what is still lacking?
Go to this place:
https://web.roblox.com/games/6990036807/Baseplate-Scripting
As you can see, you can see that the character gets up even if he has the tool equipped, also the animation of the arm with the Activated event does not play, and when I undo the tool the animation continues to play, I can also walk and jump despite having the tool equipped.
Everything is working fine for me, have you only tried it in studio or in Roblox too?
Try using this, I added an extra if statement to check if the character is in the workspace:
local Tool = script.Parent
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") 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") and Character.Parent == game:GetService("Workspace") 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
Sorry, I forgot to post, try now, Actually it should work as you saw, but now it doesn’t work
Unfortunately, it still does not work, it is exactly the same as in the place
local Tool = script.Parent
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") 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()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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
local PrimaryPart = nil
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") then
PrimaryPart = Character.PrimaryPart
if PrimaryPart then
PrimaryPart.Anchored = true
end
Humanoid = Character.Humanoid
Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6364334315" --Animation 2
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
AnimationTrack.Priority = Enum.AnimationPriority.Action
end
local Players = game:GetService("Players")
local Player = Players:GetPlayerFromCharacter(Character)
Player.leaderstats.Strength.Value += 1
wait(2)
if PrimaryPart then
PrimaryPart.Anchored = false
end
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
end
This updated code should change the AnimationPriority and anchor the HumanoidRootPart.
Edit: Fixed typo in the script
The good thing about the animation is that it works as I want and when I die it no longer gives me any error, but there is a big problem and it is that I can keep walking and jumping despite having the tool equipped, and when I undo the tool the Animation continues to play, I already published and you can enter the place so you can see it for yourself.
It is also better to use the FireServer () since the remote event is fired on the client but the script is on the server, so change it because if not you leave it in the local script, only the local player will see its strength and not the server
local Tool = script.Parent
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") 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()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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
local PrimaryPart = nil
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") then
PrimaryPart = Character.PrimaryPart
if PrimaryPart then
PrimaryPart.Anchored = true
end
Humanoid = Character.Humanoid
Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6364334315" --Animation 2
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
AnimationTrack.Priority = Enum.AnimationPriority.Action
end
local Players = game:GetService("Players")
local Player = Players:GetPlayerFromCharacter(Character)
Player.leaderstats.Strength.Value += 1
wait(2)
if PrimaryPart then
PrimaryPart.Anchored = false
end
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
end
Tool.Unequipped:Connect(Unequipped)
Animation should stop now when the tool is unequipped
The script is a server script, strength is updated on the server.
Final code should fix everything:
local Tool = script.Parent
local PrimaryPart = nil
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") then
PrimaryPart = Character.PrimaryPart
if PrimaryPart then
PrimaryPart.Anchored = true
end
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()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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") and Character.Parent == game:GetService("Workspace") 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()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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 PrimaryPart then
PrimaryPart.Anchored = false
end
if Animator then
local PlayingAnimations = Animator:GetPlayingAnimations()
for _, PlayingAnimation in pairs(PlayingAnimations) do
PlayingAnimation:Stop()
end
end
end
Tool.Unequipped:Connect(Unequipped)
local Tool = script.Parent
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") then
local Humanoid = Character.Humanoid
Humanoid.JumpHeight = 0
Humanoid.WalkSpeed = 0
local Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6350259222" --Animation 1
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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") and Character.Parent == game:GetService("Workspace") 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()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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 Humanoid then
Humanoid.JumpHeight = 7.2
Humanoid.WalkSpeed = 16
end
if Animator then
local PlayingAnimationTracks = Animator:GetPlayingAnimationTracks()
for _, PlayingAnimationTrack in pairs(PlayingAnimationTracks) do
PlayingAnimationTrack:Stop()
end
end
end
Tool.Unequipped:Connect(Unequipped)
local Tool = script.Parent
local function Equipped()
local Character = Tool.Parent
if Character and Character:FindFirstChildOfClass("Humanoid") and Character.Parent == game:GetService("Workspace") then
local Humanoid = Character.Humanoid
Humanoid.JumpHeight = 0
Humanoid.WalkSpeed = 0
local Animator = Humanoid.Animator
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6350259222" --Animation 1
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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") and Character.Parent == game:GetService("Workspace") 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()
AnimationTrack.Priority = Enum.AnimationPriority.Action
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 Humanoid then
Humanoid.JumpHeight = 7.2
Humanoid.WalkSpeed = 16
end
if Animator then
local PlayingAnimationTracks = Animator:GetPlayingAnimationTracks()
for _, PlayingAnimationTrack in pairs(PlayingAnimationTracks) do
PlayingAnimationTrack:Stop()
end
end
end
Tool.Unequipped:Connect(Unequipped)