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
Is the "seeds" thing you are trying to give the player a tool? If it isn't I don't think it will show up in the player's default backpack. If it is a tool, then your issue might be that you are putting it into starterpack, which will give the tool to every player, but only when their character respawns. If you just want to give it to one player you can put it in the player's startergear and they will get it when they respawn, or you can put it in their backpack and they will get it immediately, but won't keep it if they respawn.
Edit: I made this in my own place and it appears to do what you want. I think you might just have missed that the mouseclick event gives you the player that clicked so you can just put it right in their backpack from there.
local cd = script.Parent.ClickDetector local tool = game:GetService("ReplicatedStorage").Tool cd.MouseClick:Connect(function(player) local newtool = tool:Clone() newtool.Parent = player.Backpack end)