I want to make something like this where a food that can spawn anywhere you want on the ground
and when a player steps or walks on it it will be put on your inventory and when used/clicked once in your inventory it will disappear and heal you depends on the script on how much heal the food can give or if it can give you your max health back, and also disappears from your inventory after you eat it
Here’s a script from my healthbar in game
local front = script.Parent.FrontLayer
local textLabel = script.Parent.TextLabel
local plr = game.Players.LocalPlayer
local character = plr.Character
local tweenService = game:GetService(“TweenService”)
local healthFadeLimit = 25
local fadeFrame = script.Parent.Parent.HealthFade
function update()
local tween1 = tweenService:Create(front, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Size = UDim2.new(character:WaitForChild(“Humanoid”).Health / character:WaitForChild(“Humanoid”).MaxHealth, 0, 1, 0)})
tween1:Play()
textLabel.Text = "HEALTH "..tostring(math.floor(character:WaitForChild("Humanoid").Health + 0.5).." / "..character:WaitForChild("Humanoid").MaxHealth)
end
character:WaitForChild(“Humanoid”):GetPropertyChangedSignal(“Health”):Connect(function()
update()
if character:WaitForChild("Humanoid").Health <= 25 and character:WaitForChild("Humanoid").Health > 17 then
fadeFrame.Visible = true
local tween1 = tweenService:Create(fadeFrame.Fade, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 0.9})
tween1:Play()
elseif character:WaitForChild("Humanoid").Health <= 17 and character:WaitForChild("Humanoid").Health > 12 then
fadeFrame.Visible = true
local tween1 = tweenService:Create(fadeFrame.Fade, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 0.8})
tween1:Play()
elseif character:WaitForChild("Humanoid").Health <= 12 and character:WaitForChild("Humanoid").Health > 5 then
fadeFrame.Visible = true
fadeFrame.Visible = true
local tween1 = tweenService:Create(fadeFrame.Fade, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 0.7})
tween1:Play()
elseif character:WaitForChild("Humanoid").Health <= 5 then
fadeFrame.Visible = true
fadeFrame.Visible = true
local tween1 = tweenService:Create(fadeFrame.Fade, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 0.6})
tween1:Play()
elseif character:WaitForChild("Humanoid").Health > 25 then
fadeFrame.Visible = false
end
end)
character:WaitForChild(“Humanoid”):GetPropertyChangedSignal(“MaxHealth”):Connect(function()
update()
end)
There are a bunch of food tutorials on youtube that I can use but I dont know how to make them heal the player, them spawning in a certain time in certain place, and also disappear from your inventory after
I would appreciate the help
thank you