I want to make sure that this admin script will not cause errors when more than one number is entered. Here is the script:

			local humanoid = player.Character.Humanoid
			
			if string.lower(string.sub(msg, 1, 5)) == "speed" then
				
				local strPlayerSpeed = string.match(msg, "%d+")				
				
				if strPlayerSpeed then
					
					local numPlayerSpeed = tonumber(strPlayerSpeed)
					
					if numPlayerSpeed <= 256 then
						
						humanoid.WalkSpeed = numPlayerSpeed
						
					end
				end

My second question is what does % do in string.find and string.match local slashIndex = string.find(msg, "%/") is this the way it should be used? Also lets say I want to find a letter do I really need to use %? please tell me what it is for. Thanks!

1 comment

0

As a note, this will not catch the whole number if it is a negative and/or not an integer.