--Scripted by Electrowizard12312--
local Players = game:GetService("Players")
local cashCommand = "/give "
--
local function onOwnerChatted(player, message)
if message:sub(1, cashCommand:len()):lower() == cashCommand:lower() then
local name = message:sub(cashCommand:len() + 1)
local player = Players:FindFirstChild(name)
local amount = message:sub(cashCommand:len()+ name + 1 )
if player then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + amount
print("The creator gave "..name.." "..amount.." cash.")
else
print("Couldn't find player!")
end
end
end
--
local function onPlayerAdded(player)
if player.UserId == 586053124 then
player.Chatted:Connect(function (...)
onOwnerChatted(player, ...)
end)
end
end
--
for _, player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
-- Scripted by Electrowizard12312
This script is supposed to give cash to a player when someone chats /give player amount, but for some reason, it is considering local amount as nil(line 9) and it doesn't give any cash(No output). But if I make line 9 as 1000 or any value, it works.
How do I fix this?

2 comments
Thanks a lot, I had provided some explanation below the code.
a