so im just ganna explain my problem. so i am working on a game currently and inside the game you are supposed to collect items that get stores into your backpack which has a limited space of how many of those items you can store then you are supposed to go to a small area when if you character stands it will sell those items automatically and get exchanged money, like if you have collected wood which is in my game you sell it and get money in return. so then i next added a pet shop and it works fine you bu the pets and i tried adding a script so when you go to sell your wood for money you get x2 of the income so instead of selling 50 wood for 50 money you get 100 cash for 50 wood. so inside the pet i added this script:
workspace.BackpackShop.Sell.Part.Script(function(Hit) local Player = game.Players:FindFirstChild(Hit.Parent.Name) if Player then local leaderstats = Player:FindFirstChild("leaderstats") if leaderstats then local Money = leaderstats:FindFirstChild("Money") local Backpack = leaderstats:FindFirstChild("Wood") if Backpack.Value <= 0 then else Money.Value = Money.Value + 2 * Backpack.Value Backpack.Value = 0 script.Disabled = true wait(0.1) script.Disabled = false end end end end)
which is the same script but i tried to make it so if you have this pet the money value gets added by the x2 the amount of wood.
script inside of selling area that player steps on to sell wood:
script.Parent.Touched:connect(function(Hit) local Player = game.Players:FindFirstChild(Hit.Parent.Name) if Player then local leaderstats = Player:FindFirstChild("leaderstats") if leaderstats then local Money = leaderstats:FindFirstChild("Money") local Backpack = leaderstats:FindFirstChild("Wood") if Backpack.Value <= 0 then else Money.Value = Money.Value + 1 * Backpack.Value Backpack.Value = 0 script.Disabled = true wait(0.1) script.Disabled = false end end end end)
so can anyone help me and tell me whats wrong?