game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local args = msg:split(" ")
local plruser = args[2]
local user = game.Players:FindFirstChild(plruser)
if args[1] == "-award" and plr:GetRankInGroup(33075577) >= 228 then
if user and user.leaderstats.Exp then
local currentValue = user.leaderstats.Exp.Value
local fields = {
{
['name'] = "Info",
['value'] = "User: " .. plr.Name .. "\nRank: **" .. plr:GetRoleInGroup(33075577) .. "**",
['inline'] = true
},
{
['name'] = "Award Info",
['value'] = "User Awarded " .. user.Name .. "\nNow has **" .. currentValue .. "** EXP."
}
}
currentValue += script.Parent.Variables.Awards.AwardToGive.Value
print(" --[ Awards ]-- ")
print(" Gave "..user.Name.. " "..script.Parent.Variables.Awards.AwardToGive.Value)
print(" --[ Awards ]-- ")
user:LoadCharacter()
ws:createEmbed(url, "WARN", "This is published on 30/10/2023 11:08 pm by **RobloxSupp515**", fields)
else
print("Failed to award player, is it a correct user?")
end
end
end)
end)
You should use FindFirstChild
.
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local args = msg:split(" ")
local plruser = args[2]
local user = game.Players:FindFirstChild(plruser)
if args[1] == "-award" and plr:GetRankInGroup(33075577) >= 228 then
if user and user:FindFirstChild("leaderstats") and user.leaderstats:FindFirstChild("Exp") then
local currentValue = user.leaderstats.Exp.Value
local fields = {
{
['name'] = "Info",
['value'] = "User: " .. plr.Name .. "\nRank: **" .. plr:GetRoleInGroup(33075577) .. "**",
['inline'] = true
},
{
['name'] = "Award Info",
['value'] = "User Awarded " .. user.Name .. "\nNow has **" .. currentValue .. "** EXP."
}
}
currentValue += script.Parent.Variables.Awards.AwardToGive.Value
print(" --[ Awards ]-- ")
print(" Gave "..user.Name.. " "..script.Parent.Variables.Awards.AwardToGive.Value)
print(" --[ Awards ]-- ")
user:LoadCharacter()
ws:createEmbed(url, "WARN", "This is published on 30/10/2023 11:08 pm by **RobloxSupp515**", fields)
else
print("Failed to award player, is it a correct user?")
end
end
end)
end)
i just changed the part where
if user and user:FindFirstChild("leaderstats")
but i got ServerScriptService.Cmds.Award:21: attempt to concatenate nil with string
try using WaitForChild()
instead of FindFirstChild()
as the object you’re attempting to access may not exist yet
if user
already checks if it exists
can you show where line 21 is pls