Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[Tool for eating/drinking
- -- Does all the hunger and thirst n' stuff
- function EatDrink()
- -- Local Variables
- local playerMouse = game.Players.LocalPlayer:GetMouse()
- local playerGui = game.Players.LocalPlayer.PlayerGui
- local guivitals = playerGui.Vitals
- local playerHunger = guivitals.Hunger.HungerScript.HungerValue.Value
- local playerThirst = guivitals.Thirst.ThirstScript.ThirstValue.Value
- -- Consumeable check + hunger & thirst giving values
- if playerMouse.Target.Consumeable then
- local hunger = playerMouse.Target.Hunger.Value
- local thirst = playerMouse.Target.Thirst.Value
- -- Checks for if player is eligible to eat the food
- local ifEatenHunger = playerHunger + hunger
- local ifEatenThirst = playerThirst + thirst
- if ifEatenThirst and ifEatenHunger < 100 then
- -- Calculating portions
- local doDestroy = false
- playerMouse.Target.Portions.Value = playerMouse.Target.Portions.Value - 1
- if playerMouse.Target.Portions.Value == 0 then
- doDestroy = true
- -- Giving the player their stats
- playerHunger = playerHunger + hunger
- playerThirst = playerThirst + thirst
- print(game.Players.LocalPlayer.Name.. " has eaten ".. playerMouse.Target.Name)
- -- UI Stuff
- local hungerIncreaseBy = hunger * 4
- local thirstIncreaseBy = thirst * 4
- guivitals.Hunger.Size = UDim2.new(0, guivitals.Hunger.Size.X.Offset + hungerIncreaseBy, 0, guivitals.Hunger.Size.Y.Offset)
- guivitals.Thirst.Size = UDim2.new(0, guivitals.Thirst.Size.X.Offset + thirstIncreaseBy, 0, guivitals.Thirst.Size.Y.Offset)
- -- "To :Destroy(), or not to :Destroy(); that is the question." - William Scriptspear
- if doDestroy == true then
- playerMouse.Target:Destroy()
- else
- end
- end
- end
- end
- end
- -- Running the function
- script.Parent.Equipped:Connect(function(mouse)
- print("Equipped eat/drink tool.")
- mouse.Button1Down:Connect(EatDrink)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement