Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix ""a bad argument #1 to new"" in between Color3 and BrickColor?

Asked by 5 years ago
Edited 5 years ago

The rest of my script works and you probably do not need it.

Error: 14:57:08.831 - Workspace.Script:14: bad argument #1 to 'new' (Color3 expected, got BrickColor)

If I switch to Color3 it will say BrickColor is expected even if I add ".Color" at the end

If I use BrickColor then it will say Color3 is expected...

Players[i].TeamColor = BrickColor.new(game.Teams["Level"..Players[i].leaderstats.Level.Value].TeamColor)

If you still need the entire script then here.

MarketplaceService = game:GetService("MarketplaceService") -- Marketplace
MarketplaceService.ProcessReceipt = function(receiptInfo)
local Players = game.Players:GetPlayers()
local Level = "Level" -- string
local done = true -- bool
for i=1,#Players do
    if Players[i].userId == receiptInfo.PlayerId then
        if receiptInfo.ProductId == 325511816 and done == true then
            done = false
            Players[i].leaderstats[Level].Value = Players[i].leaderstats[Level].Value + 1
            wait()
            Players[i].TeamColor = BrickColor.new(game.Teams["Level "..Players[i].leaderstats.Level.Value].TeamColor) -- Not working 
            Players[i].Character.Humanoid.Health = 0
            done = true
        end
    end
end
return Enum.ProductPurchaseDecision.PurchaseGranted 
end

Help is appreciated

1
UserId not userId User#19524 175 — 5y
0
o ok mudathir2007 157 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

There's no reason to set a teamcolor to the brickcolor of a teamcolor. Just set the teamcolor to the teamcolor.

Basically rather than saying: TeamColor = BrickColor.new(DesiredTeamColor)

You can say: TeamColor = DesiredTeamColor

That would look like this:

Players[i].TeamColor = game.Teams["Level "..Players[i].leaderstats.Level.Value].TeamColor
0
oohh mudathir2007 157 — 5y
Ad

Answer this question