You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Getting the character’s walking animation play when the player walks and drinks the bloxy cola at the same time
-
What is the issue? The walking animation stops if I drink the Bloxy Cola and walk at the same time
-
What solutions have you tried so far? I didn’t look for solution on the Developer Hub, I remade the code (it’s below this text) and nothing really changed.
This is my code:
local tool = script.Parent
local tooltip = "It tastes different."
local handle = tool.Handle
local animations = {
drink = {
R6 = script.Parent.DrinkAnimation;
R15 = script.Parent.DrinkAnimationR15;
};
}
local health = 5 -- change this to the health you want to restore for the bloxy cola (set to 0 for none)
local sips = math.huge -- set math.huge for infinite, put another number if you want to make it limited.
local function drink()
local humanoid = tool.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local originalWalkSpeed = humanoid.WalkSpeed
humanoid.WalkSpeed = 0
local animator = Instance.new("Animator")
animator.Name = "BloxyColaAnimator"
animator.Parent = humanoid
if humanoid.RigType == Enum.HumanoidRigType.R6 then
if sips > 0 then
local animationTrack = animator:LoadAnimation(animations.drink.R6)
animationTrack:Play()
humanoid.Health = humanoid.Health + health
sips = sips - 1
tool.ToolTip=tooltip.." ("..tostring(sips)..")"
end
elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
if sips > 0 then
local animationTrack = animator:LoadAnimation(animations.drink.R15)
animationTrack:Play()
humanoid.Health = humanoid.Health + health
sips = sips - 1
tool.ToolTip=tooltip.." ("..tostring(sips)..")"
end
end
humanoid.WalkSpeed = originalWalkSpeed
end
end
tool.Activated:Connect(drink)