My previous question was why a script that was supposed to give tools wasn't working. So I managed to create a better script, which uses loops and tables. It works! But wait, when I tested it out, with Squirtle, it gave two of the same move. Charmander works fine. The move that gets cloned twice is Tackle. I don't know what's wrong.
moves = {"Ember", "Tackle", "Bubble"}
charmander = {"Ember", "Tackle"}
squirtle = {"Bubble", "Tackle"}
movestorage = workspace.Moves
plr = game.Players.LocalPlayer
script.Parent.Charmander.MouseButton1Click:connect(function()
for i = 1,#charmander do
if moves[i] == charmander[i] then
local move = movestorage:FindFirstChild(moves[i]):Clone()
move.Parent = plr.Backpack
end
end
end)
-- MY PROBLEM IS HERE --
script.Parent.Squirtle.MouseButton1Click:connect(function()
for i = 1,#squirtle do
if moves[i] == squirtle[i] then
local move = movestorage:FindFirstChild(moves[i]):Clone()
move.Parent = plr.Backpack
end
end
end)

3 comments
From a quick look, I can't tell you what is up, but I can tell you that your matching logic is flawed.
yeah i noticed
Try using a debounce in the functions if you know how to use them it's really useful and also prevents the function from running more then once with a cool down.