So um basically while i was making a warn system, and finished it, i came across a error. look to the title
local ws = require(script.Parent.WebhookService)
local url = "no am not giving you my webhook"
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local args = msg:split(" ")
local plruser = args[2]
local reason = args[3]
local user = game.Players:FindFirstChild(plruser)
if args[1] == "-warn" and plr:GetRankInGroup(33075577) >= 228 then
if user.Warns then
if user.Warns.Value == 3 then
plr:Kick("You've reached 3 warns.")
end
user.Warns.Value += 1
local fields = {
{
['name'] = "Info",
['value'] = "User: "..plr.Name, "Rank: **"..plr:GetRoleInGroup(33075577).."**",
['inline'] = true
},
{
['name'] = "Warn Info",
['value'] = "User Warned "..user.." for "..reason.." Now has "..user.Warns.Value
}
}
ws:createEmbed(url, "WARN", "This is published on 30/10/2023 9:57 pm by **RobloxSupp515**", fields)
end
end
end)
end)
local ws = require(script.Parent.WebhookService)
local url = "no am not giving you my webhook"
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local args = msg:split(" ")
local plruser = args[2]
local reason = table.concat(args, " ", 3) -- concatenate all arguments from the 3rd element to the end
local user = game.Players:FindFirstChild(plruser)
if args[1] == "-warn" and plr:GetRankInGroup(33075577) >= 228 then
if user and user:FindFirstChild("Warns") then
local warns = user.Warns.Value
if warns == 3 then
plr:Kick("You've reached 3 warns.")
else
user.Warns.Value = warns + 1
local fields = {
{
['name'] = "Info",
['value'] = "User: " .. plr.Name .. "\nRank: **" .. plr:GetRoleInGroup(33075577) .. "**",
['inline'] = true
},
{
['name'] = "Warn Info",
['value'] = "User Warned " .. user.Name .. " for " .. reason .. "\nNow has " .. user.Warns.Value
}
}
ws:createEmbed(url, "WARN", "This is published on 30/10/2023 9:57 pm by **RobloxSupp515**", fields)
end
else
plr:Kick("User not found or Warns folder not present.")
end
end
end)
end)
Heres what I’ve done:
Concatenated the reason using table.concat to ensure all words after the 3rd argument are combined into a single string.
Added a check for the existence of the user and the Warns folder to avoid errors.
Included line breaks in the “Info” field for better formatting.
Provided a helpful message if the user is not found or the “Warns” folder is missing.
local ws = require(script.Parent.WebhookService)
local url = "no am not giving you my webhook"
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local args = msg:split(" ")
local plruser = args[2]
local reason = table.concat(args, " ", 3)
local user = game.Players:FindFirstChild(plruser)
if args[1] == "-warn" and plr:GetRankInGroup(33075577) >= 228 then
if user and user:FindFirstChild("Warns") then
local warns = user.Warns.Value
if warns == 3 then
plr:Kick("You've reached 3 warns.")
else
user.Warns.Value = warns + 1
local fields = {
{
['name'] = "Info",
['value'] = "User: " .. plr.Name .. "\nRank: **" .. plr:GetRoleInGroup(33075577) .. "**",
['inline'] = true
},
{
['name'] = "Warn Info",
['value'] = "User Warned " .. user.Name .. " for " .. reason .. "\nNow has " .. user.Warns.Value
}
}
ws:createEmbed(url, "WARN", "This is published on 30/10/2023 9:57 pm by **RobloxSupp515**", fields)
end
else
plr:Kick("User not found or Warns folder not present.")
end
end
end)
end)
You’re trying to call FindFirstChild but the argument supplemented (plrusr) is nil, so it seems to me like the “args[2]” in your plrusr variable declaration doesn’t exist, and it’s clear to see why. You did “msg:split(” “)” instead of “msg.split(” “)”. So you’ve used : instead of .
Hope this works.
Attempt to concatenate Instance with string.
local user = … – user is defined as a player instance
[‘value’] = "User Warned “…user…” for " etc – user here is an instance
changed to user.Name to get user’s name as a string