Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is food script not giving food on the meat dropped after the initial meat drops?

Asked by
Vulro 0
5 years ago
Edited 5 years ago

I have animals dropping meat when defeated but only the first meat that drops is adding food when players click it. Here it is, It's a local script.

local Hunger = script.Parent.Stats["Food/Hunger"].Hunger
local Meat = workspace:WaitForChild("Meat", .1)
local Player = game.Players.LocalPlayer
local Character = Player.Character
local EatAnimation = Character.Humanoid:LoadAnimation(Character.Animations.Eat) 
local Mouse = game.Players.LocalPlayer:GetMouse()
local debounce = false


Meat.ClickDetector.MouseClick:Connect(function(player)
local Target = Mouse.Target
    if debounce == false and Hunger.Value < 100 and Target.Name == "Meat" then
     debounce = true
     EatAnimation:Play()
     Hunger.Value = Hunger.Value + 10
     script.Parent.Stats.Values.Hunger.Text = Hunger.Value
     wait(2)
     debounce = false
    end
end)
0
lol Deinonychusaurus 21 — 4y

Answer this question