Save An Egg Script by SuperNic

publicluauupdated
loadstring(game:HttpGet("https://pasteblox.com/raw/cq4cbgun6m"))()
pbx pull cq4cbgun6mraw link never changes · v1 live
save-an-egg-script-by-supernic.luau
-- EggPart -> EggSaveScript
local eggPart = script.Parent
local prompt = eggPart:WaitForChild("ProximityPrompt")

local EGG_COST = 10 -- Price to save/hatch the egg

prompt.Triggered:Connect(function(player)
	local leaderstats = player:FindFirstChild("leaderstats")
	if not leaderstats then return end

	local coins = leaderstats:FindFirstChild("Coins")
	local eggsSaved = leaderstats:FindFirstChild("EggsSaved")

	if coins and eggsSaved then
		if coins.Value >= EGG_COST then
			-- Deduct cost and reward player
			coins.Value = coins.Value - EGG_COST
			eggsSaved.Value = eggsSaved.Value + 1

			-- Visual feedback (Egg shrinks momentarily)
			eggPart.Size = eggPart.Size - Vector3.new(0.5, 0.5, 0.5)
			task.wait(0.2)
			eggPart.Size = eggPart.Size + Vector3.new(0.5, 0.5, 0.5)

			print(player.Name .. " successfully saved an egg!")
		else
			-- Not enough coins notification/feedback
			warn(player.Name .. " does not have enough coins!")
		end
	end
end)

changelog

1 version
  1. first version

    live

    @ncrizare·