Hello, so I am completely debugging my game, and I found a bug where the nametags should be changing colors, but it’s not. It had the math.Random function, but I didn’t want that. Instead, I wanted colors from BrickColors. How would I transfer the brick colors to Color3? (I tried using the RGB color picker, but it also didn’t work…)
Script:
local TweenService = game:GetService(“TweenService”)
local MarketPlaceService = game:GetService(“MarketplaceService”)
local gamePassId = GamepassID_Here
local groupId = GroupID_Here
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local GuiClone = script.OverheadGui:Clone()
GuiClone.Parent = Character.Head
local InformationLabel = GuiClone.InformationLabel
local PlayerRank = Player:GetRoleInGroup(groupId)
InformationLabel.Text = Player.Name .. " - " .. PlayerRank
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
while true do
local colors = {Color3.new "128, 187, 219","255, 89, 89", "177, 229, 166", "177, 167, 255", "255, 152, 220"}
local ColorTween = TweenService:Create(InformationLabel, TweenInfo.new(3), {BrickColor.new})
ColorTween:Play()
wait(3)
end
end
end)
end)
Please help if you can! (Add a modified script that would work if possible, I don’t know lua that well yet!)
flkfv
(flkfv)
April 25, 2021, 11:07pm
2
local TweenService = game:GetService("TweenService")
local MarketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 16996503
local groupId = 9789396
local colors = {
Color3.fromRGB(128, 187, 219),
Color3.fromRGB(255, 89, 89),
Color3.fromRGB(177, 229, 166),
Color3.fromRGB(177, 167, 255),
Color3.fromRGB(255, 152, 220)
}
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local GuiClone = script.OverheadGui:Clone()
GuiClone.Parent = Character.Head
local InformationLabel = GuiClone.InformationLabel
local PlayerRank = Player:GetRoleInGroup(groupId)
InformationLabel.Text = Player.Name .. " - " .. PlayerRank
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
while true do
local color = colors[math.random(1, #colors)]
local ColorTween = TweenService:Create(InformationLabel, TweenInfo.new(3), {TextColor3 = color})
ColorTween:Play()
ColorTween.Completed:Wait()
end
end
end)
Also if you want to convert a BrickColor to a Color3 simply use the Color property inside the BrickColor
Your script is a bit unclear, complicated and incorrect. Simply use,
local list = {
Color3.fromRGB(128, 187, 219),
Color3.fromRGB(255, 89, 89),
Color3.fromRGB(177, 229, 166),
Color3.fromRGB(177, 167, 255),
Color3.fromRGB(255, 152, 220)
}
local randomColor = list[math.random(1, #list)]
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
while true do
local ColorTween = TweenService:Create(InformationLabel, TweenInfo.new(3), randomColor)
ColorTween:Play()
wait(3)
end
end
1 Like
flkfv
(flkfv)
April 25, 2021, 11:15pm
4
Yeah, I’m currently tired which is why some of my coding might be wrong
Edit: Fixed the errors
1 Like
No problem!
You just wrote tables in a table so it won’t get the colors.
And also last square bracket is missing. ]
1 Like
So would either of these scripts replace the whole script?
No, combine the script I wrote above. It is just additional.
local TweenService = game:GetService(“TweenService”)
local MarketPlaceService = game:GetService(“MarketplaceService”)
local gamePassId = GamepassID_Here
local groupId = GroupID_Here
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local GuiClone = script.OverheadGui:Clone()
GuiClone.Parent = Character.Head
local InformationLabel = GuiClone.InformationLabel
local PlayerRank = Player:GetRoleInGroup(groupId)
InformationLabel.Text = Player.Name .. " - " .. PlayerRank
local list = {
Color3.fromRGB(128, 187, 219),
Color3.fromRGB(255, 89, 89),
Color3.fromRGB(177, 229, 166),
Color3.fromRGB(177, 167, 255),
Color3.fromRGB(255, 152, 220)
}
local randomColor = list[math.random(1, #list)]
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
while true do
local ColorTween = TweenService:Create(InformationLabel, TweenInfo.new(3), randomColor)
ColorTween:Play()
wait(3)
end
end
end)
end)
try this
local TweenService = game:GetService(“TweenService”)
local MarketPlaceService = game:GetService(“MarketplaceService”)
local gamePassId = 00000
local groupId = 0000
local colors = {
Color3.fromRGB(128, 187, 219),
Color3.fromRGB(255, 89, 89),
Color3.fromRGB(177, 229, 166),
Color3.fromRGB(177, 167, 255),
Color3.fromRGB(255, 152, 220)
}
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local GuiClone = script.OverheadGui:Clone()
GuiClone.Parent = Character.Head
local InformationLabel = GuiClone.InformationLabel
local PlayerRank = Player:GetRoleInGroup(groupId)
InformationLabel.Text = Player.Name .. " - " .. PlayerRank
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
while true do
local color = colors[math.random(1, #colors)]
local ColorTween = TweenService:Create(InformationLabel, TweenInfo.new(3), {TextColor3 = color})
ColorTween:Play()
ColorTween.Completed:Wait()
end
end
end)
end)
i think i fixed his errors
he for got a closing bracket and an end
ProBaturay
(Programmer)
April 25, 2021, 11:33pm
12
Sorry, randomColor in the Create function must be used in {} (As far as I know)
local ColorTween = TweenService:Create(InformationLabel, TweenInfo.new(3), {randomColor})
Its still not working, but TweenService, MarketPlaceService, and randomColor all have a blue underline. Would you by chance have to add:
local TweenService = game:GetService(“TweenService”)
local MarketPlaceService = game:GetService(“MarketPlaceService”)
Somewhere in the script? And if so, what for randomColor? Would you use math.Random instead of randomColor?
try this
local TS = game:GetService("TweenService")
local MPS = game:GetService("MarketplaceService")
local gamePassId = 16996503
local groupId = 9789396
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local GuiClone = script.OverheadGui:Clone()
GuiClone.Parent = Character.Head
local InformationLabel = GuiClone.InformationLabel
local PlayerRank = Player:GetRoleInGroup(groupId)
InformationLabel.Text = Player.UserId == 1904982737 .. " - " .. PlayerRank
if MPS:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
while true do
local list = {
Color3.fromRGB(128, 187, 219),
Color3.fromRGB(255, 89, 89),
Color3.fromRGB(177, 229, 166),
Color3.fromRGB(177, 167, 255),
Color3.fromRGB(255, 152, 220)
}
local randomColor = list[math.random(1, #list)]
local ColorTween = TS:Create(InformationLabel, TweenInfo.new(3), {randomColor})
ColorTween:Play()
wait(3)
end
end
end)
end)
@ItsKoolPlayz what are the gamepass id and group id
local gamePassId = 16996503
local groupId = 9789396
1 Like
ProBaturay
(Programmer)
April 25, 2021, 11:44pm
17
I couldn’t understand what you want to say, explain a bit more.
I have already used math.random in randomColor variable. It will choose a color from the list.
And also MarketPlaceService is not a service. You should use instead MarketplaceService . P is not capitalized.
Do you have any error in the output?
Don’t know, it makes it hard to know when my computer crashes when I test a game in studio… There’s no errors in the script, nor the Script Analysis.
local TS = game:GetService("TweenService")
local MPS = game:GetService("MarketplaceService")
local gamePassId = 16996503
local groupId = 9789396
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local GuiClone = script.OverheadGui:Clone()
GuiClone.Parent = Character.Head
local InformationLabel = GuiClone.InformationLabel
local PlayerRank = Player:GetRoleInGroup(groupId)
InformationLabel.Text = Player.UserId == 1904982737 .. " - " .. PlayerRank
if MPS:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
while true do
local list = {
Color3.fromRGB(128, 187, 219),
Color3.fromRGB(255, 89, 89),
Color3.fromRGB(177, 229, 166),
Color3.fromRGB(177, 167, 255),
Color3.fromRGB(255, 152, 220)
}
local randomColor = list[math.random(1, #list)]
local ColorTween = TS:Create(InformationLabel, TweenInfo.new(3), {randomColor})
ColorTween:Play()
wait(3)
end
end
end)
end)
So, How Did this Work Out? Good Or Bad @ItsKoolPlayz ?
It kinda broke the whole nametag…