Hello all! So I am scripting a warning system for a hotel type game but when it comes to setting the text above a players head to something like W1 - Trolling and when I am setting the Warning to be Warning 1 for example, the amountOfWarnings.Value returns nil even after adding 1 to the amountOfWarnings.Value. This then prints: attempt to concatenate string with nil.
Does anyone know how to fix this? Thanks!
Is amountOfWarnings an IntValue or NumberValue? If it’s either, it can’t be the reason for the error. Try checking if reasonForWarn has a value attached to it.
Hmm. Alright.
This will be a bit of a hacky method, but you could do:
local reasonForWarn = string.sub(msg, #split[1] + #split[2] + 2, #msg)
Edit for anyone coming to this post later:
The code that was an issue was this:
plr.Chatted:Connect(function(msg)
local split = msg:split(" ")
if plr.Name == "kry1068" and split[1] == ":warn" then
local warnedPlayerName = split[2]
local warnedPlayer = game.Players:FindFirstChild(warnedPlayerName)
local reasonForWarn = split[warnedPlayerName]
Where OP tried to access a point in an array using a name, not an index. OP actually intended for it to be any remaining characters after the split[2]. This was solved by using the string.sub method above.