This script is located in ServerScriptService but doesn't add the Value although adds everything else
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("Tiles") game.Players.PlayerAdded:Connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local tiles = Instance.new("IntValue",leader) tiles.Name = "TilesColored" tiles.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, tiles.Value) local ye = Instance.new("BrickColorValue",player) ye.Name = "colorval" ye.Value = math.random() end)
Good afternoon!
math.random()
returns a random number. BrickColorValue's
Value property is of type BrickColor, not number.
I believe you're looking for BrickColor.Random()
Line 17 should be:
ye.Value = BrickColor.Random()
As far as the BrickColorValue not appearing in the player, I've put your code in studio and it seems to function as intended. Be sure that your script is NOT a LocalScript and is inserted in ServerScriptService.
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("Tiles") game.Players.PlayerAdded:Connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local tiles = Instance.new("IntValue",leader) tiles.Name = "TilesColored" tiles.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, tiles.Value) local ye = Instance.new("BrickColorValue",player) ye.Name = "colorval" ye.Value = BrickColor.Random() end)
In the future, you should also refrain from parenting new objects before setting their properties. You can read about why here