wait(0.5)
local Animation = script:WaitForChild("Animation")
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
--Load the animation
local animationTrack = hum:LoadAnimation(Animation)
local mouse = player:GetMouse()
local isPlaying = false
local numDrank = 0
mouse.Button1Down:Connect(function()
wait(0.1)
--Check if he has an item, if yes let the animation begin
local function findItem(char)
for i,v in next, char:GetChildren() do
if v:IsA("Tool") then
return v
end
end
end
local item = findItem(char)
if item then
--He has an item, let the animation play
--Check if it's playing already or not
if isPlaying == false then
isPlaying = true
animationTrack:Play()
animationTrack.Stopped:Connect(function()
if numDrank >= 5 then
numDrank = 0
--Destroy it
--Fire a Remote Event
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MaxTimes = ReplicatedStorage.Remotes.MaxTimes
--Fire it
local invoke = MaxTimes:InvokeServer(item)
else
isPlaying = false
numDrank = numDrank + 1
end
end)
end
end
end)
wait(0.5)
local ContentProvider = game:GetService("ContentProvider")
local Animation = ContentProvider:PreloadAsync(script.Animation)
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
--Load the animation
local animationTrack = hum:LoadAnimation(Animation)
local mouse = player:GetMouse()
local isPlaying = false
local numDrank = 0
mouse.Button1Down:Connect(function()
wait(0.1)
--Check if he has an item, if yes let the animation begin
local function findItem(char)
for i,v in next, char:GetChildren() do
if v:IsA("Tool") then
return v
end
end
end
local item = findItem(char)
if item then
--He has an item, let the animation play
--Check if it's playing already or not
if isPlaying == false then
isPlaying = true
animationTrack:Play()
animationTrack.Stopped:Connect(function()
if numDrank >= 5 then
numDrank = 0
--Destroy it
--Fire a Remote Event
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MaxTimes = ReplicatedStorage.Remotes.MaxTimes
--Fire it
local invoke = MaxTimes:InvokeServer(item)
else
isPlaying = false
numDrank = numDrank + 1
end
end)
end
end
end)