I want to make /donate command and give player the time.
but stillhas “nil” error…
can u fix…?
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(plr)
for i,v in pairs (game.Players:GetChildren()) do
plr.Chatted:Connect(function(msg)
local NumberFromString = string.match(msg , "%d+")
local timetodonate = tonumber(NumberFromString)
if string.find(msg, "/donate")..tostring(NumberFromString) then
for i, v in pairs(game.Players:GetChildren()) do
if string.find(msg, string.lower(v.Name)) then
if plr.leaderstats.Time.Value > timetodonate then
print(plr.Name.. " gave ".. NumberFromString.. " time to "..v.Name)
plr.leaderstats.Time.Value = plr.leaderstats.Time.Value - timetodonate
v.leaderstats.Time.Value = plr.leaderstats.Time.Value + timetodonate
end
end
end
end
end)
end
end)