Info
I’m trying to make a give tool command, this works for the most part but there is one issue I can not seem to work around.
Expected Behavior
If you give say Roblox the same tool twice, it should only give the player the tool twice.
Actual Behavior
It gives the player the tool, not twice but double that.
Workarounds
None.
Cause of Problem
From what I can tell, I believe it happens because it loops through the players but I have no idea what I can do to change/fix that. I have tried changing the position of the tools and the player and nothing changes.
Code
["Tool Giver Command"] = { --Title of the Command
CommandPhrases = {"give","tool"}; --You Add the words you want to say to have run Command Below.
Level = 6,
Description = "This is where the commands description will be.";
Function = function(plr,message) --This is the function, meaning the thing that makes the command work. You won't have to worry about this by much.
local Module,Players,Settings = CommunicationModule.FindModule("Functions"),CommunicationModule.FindService("Players"),CommunicationModule.FindModule("Settings")
local TableOfPlayers = Module.Functions["Find Player"](plr,message) --Gets a table of all the players names.
local TableOfTools = Module.Functions["Find Tool"](plr,message) --Gets a table of all the tool names.
print(TableOfTools)
for _,PlayerName in pairs(TableOfPlayers) do
print(PlayerName.." has been passed")
for index,Tool in pairs (TableOfTools) do
print(Tool.. " has been given.")
warn(Tool)
local ClonedTool = Settings.Variables.ToolsFolder[Tool]:Clone()
ClonedTool.Parent = game.Players[PlayerName].Backpack
end
end
end}
Thank you for any help you can give.
Eleven Hours Later