I tried creating a bread tool that when clicked, it would heal the player by 25 health. I did this all in a ServerScript, I don't know if I need to use a LocalScript.
My Code:
local bread = script.Parent
local breadHandle = bread.Handle
function onClick(player)
if player.Character.Humanoid.Health > 100 then
player.Character.Humanoid.Health = player.Character.Humanoid.Health + 25
breadHandle.Yummy:Play()
wait(1)
bread:Destroy()
else
local msg = Instance.new("Message")
msg.Parent = workspace
msg.Name = "Msg"
msg.Text = "You are already at max health! Get damaged then use the bread."
end
end
bread.Activated:Connect(onClick)

1 comment
One. Dont use Message wtf, Two. Use bread.Activated:Connect(function(player) instead of function onClick(). Three. to get the player use FindFirstAncestor() You need to