New Chat Service Displaying[NOT SOLVED]

I want to make a RNG game, which is working from my previous topics, but if the player rolls 1/1k to 1/9.99k, I want to display the message in all cilents to let them know a player has rolled the amount.

Firing Script:

local chat = game.ReplicatedStorage.ChatEvents.Chat
chat.OneIn1K:FireAllClients(plr, index[2])

StarterCharacterScript:

local c = game.ReplicatedStorage.ChatEvents.Chat
local FormatNumber = require(game.Workspace.FormatNumber.Main)
local formatter = FormatNumber.NumberFormatter.with()

c.OneIn1K.OnClientEvent:Connect(function(plr, index[2]) -- Error Line
	if index[2] >= 1000 then
		local displayer = formatter:Format(index[2])
		local Message = (plr.Name.." has rolled an 1/"..displayer.."!") -- I can't figure out how to chance the text color to gold, too
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(Message)
	end
end)

But. I’m getting this weird error Expected ')' (to close '(' at column 41), got '['. I cannot explain this and I can’t see what’s wrong with that. Help is appreciated!

local c = game.ReplicatedStorage.ChatEvents.Chat
local FormatNumber = require(game.Workspace.FormatNumber.Main)
local formatter = FormatNumber.NumberFormatter.with()

c.OneIn1K.OnClientEvent:Connect(function(plr, index)
	if index >= 1000 then
		local displayer = formatter:Format(index[2])
		-- Gold hex code: #ffaa00
		local Message = `<font color="#ffaa00">{plr.Name} has rolled an 1/"..{displayer}.."!</font>`
		game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage(Message)
	end
end)

attempt to index number with number
This is the error line: local displayer = formatter:Format(index[2])

Replace it with this instead
local displayer = formatter:Format(index)

It worked well, even the formatter, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.