I'm trying to make a command that allows the user to set someones gold based on a few factors:
"plrName" & "GoldValue" are both there - True
If the "plrName" is made up of digits (UserId) and the "GoldValue" is also made up of digits, then tell the output that the player is numbers and carry on to load the players stats by using the "plrName" (UserId) in the module, and then saving the new GoldValue.
Elseif the "plrName" is not all digits, then it's a name (if it isn't made up). From here, grab the players Id from the name given, if it exists and load the players stats and update their gold.
===== The Problem =====
No matter what string I have attempted to use, the second if statement that checks if the "plrName" is just digits isn't picking anything up and i'm not sure if i'm using the format correctly or not...
The second statement works fine on the (name > ID > LoadId > Change stats.)
But, as the digit statement is being ignored, it's being sent to the name statement and it's causing it to fail and error...
Any ideas on what i'm doing wrong. - Wrong String property?, using it wrong? I have no idea
Thank you in advance.
return function(Speaker, plrName, GoldValue )
local playerDataModule = require( game.ServerScriptService.DataStores.theSystem.PlayerDataModule )
local Players = game:GetService("Players")
if plrName and GoldValue then
if string.match(plrName,"%D+") and string.match(GoldValue, "%D+") then
print("Player is numbers")
local LoadStats = playerDataModule.LoadPlayerStats(plrName)
local playerName = Players:GetNameFromUserIdAsync(plrName)
LoadStats.Gold = GoldValue
print( string.format("Changed player '%s', gold to '%d'", playerName,GoldValue) )
elseif plrName ~= nil and string.format(GoldValue, "%D+") then
print("Player has letters")
local userid = Players:GetUserIdFromNameAsync(plrName)
local playerName = Players:GetNameFromUserIdAsync(userid)
local LoadStats = playerDataModule.LoadPlayerStats(userid)
LoadStats.Gold = GoldValue
print( string.format("Changed player '%s', gold to '%d'", playerName,GoldValue) )
end
else
warn( string.format("command '%s' got invalid arguments. Skipping..", script.Name ) )
end
end
