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

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

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

1 comment

0

What is the GetAsync returning? The problem looks to be there, as "Color3.fromRGB(255, 255, 255)" should work.

1 answer

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!

1 comment

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.

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