Hello. I’m currently trying to make a cash giver script, but I keep getting an error (shown below). Any help would be greatly appreciated. Thanks.
local cashCmd = ":cash "
local levelCmd = ":level "
local ownerId = 219993365
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if player.UserId == ownerId then
if msg:sub(1, cashCmd:len()):lower() == cashCmd:lower() then
local username = msg:sub(cashCmd:len()+1):lower()
local cashAmount = msg:sub(username:len()+1):lower()
local playerName = game.Players:GetChildren(username)
playerName.leaderstats.Cash.Value = cashAmount
end
if msg:sub(1, levelCmd:len()):lower() == levelCmd:lower() then
local levelAmount = msg:sub(levelCmd:len()+1):lower()
player.leaderstats.Level.Value = levelAmount
end
end
end)
end)