Hello! I’m trying to find a model within a player with model names put into a table. Except an error is showing in the output as
argument#1 expects a string, but table was passed
Here is a snippet of the server-side code:
RepaintEvent.OnServerEvent:Connect(function(
Player,
PrimaryColourR, PrimaryColourG, PrimaryColourB,
SecondaryColourR, SecondaryColourG, SecondaryColourB,
TertiaryColourR, TertiaryColourG, TertiaryColourB
)
local Credits = Player.leaderstats.Credits
local DroidOwned = Player.Droids.Owned
if DroidOwned.Value == true and Credits.Value >= DroidModule.Repaint.BuyPrice then
local Droid = {}
for i,v in pairs(DroidModule) do
table.insert(Droid, v.Name)
end
if Player.Character:FindFirstChild(Droid) then
Credits.Value -= DroidModule.Repaint.BuyPrice
game.Workspace:FindFirstChild("Primary").Color = Color3.fromRGB(PrimaryColourR, PrimaryColourG, PrimaryColourB)
game.Workspace:FindFirstChild("Secondary").Color = Color3.fromRGB(SecondaryColourR, SecondaryColourG, SecondaryColourB)
game.Workspace:FindFirstChild("Tertiary").Color = Color3.fromRGB(TertiaryColourR, TertiaryColourG, TertiaryColourB)
end
end
end)
And here is the table in a module script:
local DroidPrices = {
["Repaint"] = {
Name = "Repaint",
BuyPrice = 2000
},
["Groundmech"] = {
Name = "Groundmech",
BuyPrice = 25000,
SellPrice = (25000 * 0.65)
},
["Astromech"] = {
Name = "Astromech",
BuyPrice = 38000,
SellPrice = (38000 * 0.65)
},
["BuddyDroid"] = {
Name = "BuddyDroid",
BuyPrice = 50000,
SellPrice = (50000 * 0.65)
}
}
return DroidPrices