Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

1

UserId not userId

0

o ok

1 answer

✓ Accepted answer

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

1 comment

0

oohh

This discussion is preserved as it was. New answers, comments, and votes are closed.