3.
"Pet Plant Paradise"
Genre: Simulator
Concept: Players grow magical pet plants that need love and attention. The
plants evolve into different forms (like flowers, trees, or cute creatures). You
can trade plants with others and unlock new seeds.
Code for breaking coins
local clickDetector = script.Parent
local coinModel = clickDetector.Parent
-- Configuration
local respawnTime = 3
local basePosition = coinModel:GetPivot().Position -- Use the model's starting Y position
local respawnAreaMin = Vector3.new(-50, basePosition.Y, -50)
local respawnAreaMax = Vector3.new(50, basePosition.Y, 50)
local isDebounce = false -- Prevent multiple clicks while respawning
-- Helper function to set transparency and collision for all parts in the model
local function setModelState(model, transparency, canCollide)
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Transparency = transparency
descendant.CanCollide = canCollide
end
end
end
-- Function to handle the click event
local function onClick(player)
if isDebounce then return end -- Exit if already processing a click
isDebounce = true
print(player.Name .. " clicked the coin model: " .. coinModel.Name)
-- Add coin awarding logic here if needed
-- Hide the coin model
setModelState(coinModel, 1, false)
-- Wait for respawn time
task.wait(respawnTime)
-- Calculate new random position within the area
local randomX = math.random(respawnAreaMin.X, respawnAreaMax.X)
local randomZ = math.random(respawnAreaMin.Z, respawnAreaMax.Z)
local randomPosition = Vector3.new(randomX, basePosition.Y, randomZ) -- Keep original Y
-- Create the target CFrame (position only, keeps original orientation)
local targetCFrame = CFrame.new(randomPosition)
-- Move the model to the new position
coinModel:PivotTo(targetCFrame)
-- Show the coin model again
setModelState(coinModel, 0, true)
isDebounce = false -- Allow clicking again
end
-- Connect the click event
clickDetector.MouseClick:Connect(onClick)
print("Breakable coin script loaded for:", coinModel.Name)