I'm probably making an obvious mistake here, but I've tried lots of different routes to try and solve this problem, none of which have worked.

My script is:

local colourSave = game:GetService("DataStoreService"):GetDataStore("vehicleStats")
local key = ""
local Colour = Color3.new(127/255,127/255,127/255)

game.Players.PlayerAdded:connect(function(plr)
	key = "player_"..plr.UserId
	local initCheck = colourSave:GetAsync(key)
		if initCheck == nil then
			colourSave:SetAsync(key,tostring(Colour))
		end
	wait(1)
		for i, v in pairs(game.Workspace.ViewModel.Ranger.Body.Paint:GetChildren()) do
			v.Color = Color3.new(colourSave:GetAsync(key))
		end
			print(Color3.new(colourSave:GetAsync(key))) --debug
end)

game.ReplicatedStorage.vehicleStats.flashColour.OnServerEvent:connect(function(player, colour)
	colourSave:SetAsync(key,tostring(colour))
end)

The "colour" parameter received from the flashColour remote event looks something like this: 0.84532, 0.23536, 0.012463

I'm not sure what I'm doing wrong, so if anyone could help me with this, I'd greatly appreciate it.

5 comments

0

Why are you dividing 127 by 255?

1

Based on the research I've done, it seems that Color3 accepts decimal values between 0.0 and 1.0, so I thought it would make sense to set up the Colour variable that way.

0

You're storing the string "0.84532, 0.23536, 0.012463" into your datastore. Try converting this back into a color via Color3.new("0.84532, 0.23536, 0.012463"), which is what you're doing right now, and see what color you're generating.

0

Instead of saving the string, save the color as a table {Colour.r, Colour.g, Colour.b}, and convert this back to a color using Color3.new(unpack({Your saved table}).

0

That worked perfectly, thanks!