Hello, I want to stop the player when playing the coconut eating animation. I need to make the player unable to move forward or backward in any way. Thank you in advance.
There is probably a better way to do this, but you would need to set both humanoid.JumpPower and humanoid.WalkSpeed values to 0. That would make the player unable to move. I would start detecting if the player is moving first though, if they aren’t moving then it would still function nonetheless.
(just a side note, do this if y’want.)
If you don’t want them to rotate at all while eating the coconut, you could set their AutoRotate feature off which is inside of the Humanoid in the character. When the animation stops playing, you can turn the autorotate feature back on so that the player can start rotating on their own again. I’m pretty sure you can check when an animation is done playing, I think it was AnimTrack.Ended or something like that?
Thank you very much. You helped me a lot. I’m sorry but could you show an example of how to write this script. It’s quite difficult for me, I only know basic scripts.
I will give you a recreation of your script and a few resources to maybe help you learn a little more about what I have talked about.
Here is the script:
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local tool = script.Parent
local anims_table = {
coco_anim = tool:WaitForChild("Animations").Animation
}
local current_Walk_speed = humanoid.WalkSpeed
humanoid.WalkSpeed = current_Walk_speed
local current_jump_Power = humanoid.JumpPower
humanoid.JumpPower = current_jump_Power
local can_Activate = true
local track = humanoid.Animator:LoadAnimation(anims_table.coco_anim)
tool.Activated:Connect(function()
if player and can_Activate then
can_Activate = false
track.Priority = Enum.AnimationPriority.Action
track.Looped = false
track:Play()
if humanoid.MoveDirection.Magnitude > 0 or humanoid.MoveDirection.Magnitude <= 0 then
humanoid.AutoRotate = false
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
end
track.Stopped:Wait()
humanoid.AutoRotate = true
humanoid.WalkSpeed = current_Walk_speed
humanoid.JumpPower = current_jump_Power
wait(2)
can_Activate = true
end
return tool
end)
I do recommend adding a FOLDER inside of your TOOL, which could be something to store your ANIMATIONS in instead of creating and destroying animations which could change how the game functions in FPS. I do have a picture of the setup just incase you don’t understand what i’m talking about. Also, add a TABLE into your script so you can store your animations into that table, that way you don’t have to create multiple variables and make the script look all messy and unorganized.
Bro sorry, have a problem, can you drop picture pls. I create folder named “Animations”
but i have Infinite yield possible on 'Players.MaaXGaz20.Backpack.Coconut:WaitForChild(“Animations”)
What i need to do?