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

[EDIT] Error: 'Color3 expected, got string'?

Asked by 7 years ago
Edited 7 years ago
despairitemcolor.Value = despairitemcolords:GetAsync(player.UserId) or Color3.fromRGB(255, 255, 255)

The full error says

20:07:02.858 - ServerScriptService.SetupInventory:37: bad argument #3 to 'Value' (Color3 expected, got string)

The value type is Color3Value, and I dont really understand why Color3.fromRGB (255, 255, 255) would be read as a string.

EDIT A very similar line works perfectly though:? despair.Value = despairds:GetAsync(player.UserId) or false

0
What is the GetAsync returning? The problem looks to be there, as "Color3.fromRGB(255, 255, 255)" should work. call23re2 87 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

It is most likely because when :GetAsync() was called, it returned a string. When or is used after a statement that returns something (like GetAsync), the or and anything after that will only be called if the initial statement is nil. So, when despairitemcolords:GetAsync(player.UserId) is called, if that value is not nil, the Color3 will not come out. To fix this, simply remove the GetAsync

despairitemcolor.Value = Color3.fromRGB(255, 255, 255)

If I helped, accept my answer please!

0
The :GetAsync() is used to get the color from past sessions. If you are farmiliar with Rocket League, it's like coming back with your colored Zombas saved. SchonATL 15 — 7y
Ad

Answer this question