In a game I am making, I wanted players to be able to be able to withdraw and deposit party members of different types in and out of their group. The withdrawing part is working how I want it to, but the depositing is proving to be a bit of a hassle. Instead of one party member being deposited, all of it's type are deposited instead. How can I make this script only activate once, even though there are multiple members possible. I hope I made that understandable because I don't really know how to describe it. Here is the script:
function onClicked()
local plr = script.Parent.Parent.Parent.Parent.Parent
local store = plr.OnionStore.Yellow
local num = plr.Character.Num
local max = plr.Character.Max
if num.Value ~= 0 then
local b = plr.Character:GetChildren()
for index, item in pairs(b) do
if item.Name == "Pikmin" and item.Available.Value == true then
local list = item:children()
local temp = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
print("Worked this far")
if (temp2.className == "NumberValue") and (temp2.Name == "Pik") and (temp2.Value == 2) then
temp = temp2.Parent
temp.Leaf.Sound.Volume = 0
temp:Destroy()
store.Value = store.Value + 1
num.Value = num.Value - 1
end
end
end
end
end
end
script.Parent.MouseButton1Click:connect(onClicked)

1 comment
it doesnt work cuz u use a mix of deprecated andn non deprecated stuff