Hey all I'm figuring out the systems that are needed in place for this farming game im making and so im having trouble with this script on getting seeds into the player's inventory when they harvest whatever plant they are growing. I've tried many solutions, but they wouldn't work. Script looks kinda bad but lemme know if you have a solution to this!
Keep in mind, this is on a regular script so im not sure if i should use a LocalScript for this.
Thanks!
local plantPart = script.Parent
local ClickDetector = script.Parent:FindFirstChild("ClickDetector")
wait(3)
plantPart.Size = Vector3.new(4,2,4)
wait(3)
plantPart.Size = Vector3.new(4,3,4)
wait(3)
plantPart.Size = Vector3.new(4,4,4)
wait(3)
plantPart.Size = Vector3.new(4,5,4)
if plantPart.Size == Vector3.new(4,5,4) then
print("Ready to Harvest!")
ClickDetector.MouseClick:Connect(function(player)
plantPart:Destroy()
if plantPart:Destroy() or plantPart.Size == Vector3.new(4,5,4) then
local Money = player.leaderstats.Money
Money.Value = Money.Value + 5
local PlayerSeeds = game:GetService("ReplicatedStorage").Seeds:Clone()
local PlayerInv = game:GetService("StarterPack")
PlayerSeeds.Parent = PlayerInv
end
end)
end

4 comments
Yes the seeds object is indeed a tool, its supposed to get put into the backpack when the player harvests a plant when its big enough. The trouble is that i don't have a proper solution as to how to reference the backpart part of the player correctly.
backpack is a descendent of player, and you are getting player from the clickdetector function so you could just do PlayerSeeds.Parent = player.Backpack
Holy cow, it works. Thx a lot!
yep