Hello,
So I am trying to make a sell area but I made a SellBonus value so if you put it at 2 you should get 2x money but it is not working. The error is "Error trying to use a local value "multi" (nil value)"
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 Cash = leaderstats:FindFirstChild("Cash")
local Backpack = leaderstats:FindFirstChild("Bag")
local multi = leaderstats.Parent:FindFirstChild("PlayerStats").SellBonus
if Backpack.Value <= 0 then
else
if Backpack.Value > 25 then
Backpack.Value = 25
else
end
Cash.Value = Cash.Value + multi * Backpack.Value
Backpack.Value = 0
script.Disabled = true
wait(0.1)
script.Disabled = false
end
end
end
end)
Anybody know why? Also I made a mistake I did not put value but well I sell it gives nothing...

3 comments
waitforchild is your best friend.
For line 16, you need Cash.Value = Cash.Value + multi.Value * Backpack.Value. I think the reason being is because you are just getting a int value on line 08 and not the value of the int value
waitforchild in this case shouldn't matter because everything should be loaded in by the time that the part is touched by a player, but it might be smart to add a check if there is a humanoid value inside player