Yeah as the title says, i dont have a clue how i’d get around doing this, i want to gen random strings to name items in my game to help make it more anti-exploitable
If I were you, I’d put each alphabet in a table and use random
You shouldn’t name your items randomly. How will you, as the developer, access these items when they will have random names?
@NastyFeat Thank you ill give this a go
@sjr04 They all have scripts that are local to each button, dont worry ive thought about this.
You shouldn’t do security through obscurity. This gives a false sense of security. What about your game is being exploited that you need to unnecessarily obfuscate names?
I think you should focus on a better client–server model rather than putting a band-aid over current issues.
Its a button pressing game. Somebody has created a script that teleports you to all the buttons in a fast loop and the script is all over v3rm so the exploit is widely available.
I wouldn’t worry too much about trying to prevent exploiters by naming things differently. They will find a way around this. It would be wise to look into ways to make your code bullet proof by having the server check and validate requests made by clients.
Anyways, random letters…
local random = Random.new()
local letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
function getRandomLetter()
return letters[random:NextInteger(1,#letters)]
end
function getRandomString(length, includeCapitals)
local length = length or 10
local str = ''
for i=1,length do
local randomLetter = getRandomLetter()
if includeCapitals and random:NextNumber() > .5 then
randomLetter = string.upper(randomLetter)
end
str = str .. randomLetter
end
return str
end
print(getRandomString(7, true))
How will i name every button?
I attempted this but obviously it will not work
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Cost") then --Checks if its a button
v.Name = getRandomString(10,true) --Randomly generates a name
end
end
Again, I don’t think that this is a valid solution to your problems.
function checkNameChange(obj)
if obj and obj.Parent then
if obj.Name == 'Cost' then
obj.Name = getRandomString(10, true) -- Randomly generates a name
end
end
end
-- Check all existing objects
for _,obj in pairs(workspace:GetDescendants()) do
checkNameChange(obj)
end
-- Check all objects that get created later
workspace.DescendantAdded:connect(checkNameChange)
Edit: I just noticed that you want to change the name of objects with a “Cost” tag under them, not change the name of the cost tags themselves. You can adjust the obj.Name = X to obj.Parent.Name = X
A lot of the responses of this thread seem to be unnecessary unless you’re looking for a very specific kind of random string. Your best bet is to use the HttpService’s GenerateGUID function in order to generate a random string to use for whatever purpose you may need it for. It works as seen below:
local HttpService = game:GetService("HttpService")
local RandomString = HttpService:GenerateGUID(false)
An example of what this function will return is “db454790-7563-44ed-ab4b-397ff5df737b
”. The boolean parameter is whether to add curly braces around the string or not.
You don’t need a table for this, you can just use string.char
. Quick example of its usage:
local min, max, final = ("a"):byte(), ("z"):byte(), ""
for i = 1, whatever do
final ..= string.char(math.random(min, max))
end
Basically, it just turns an ASCII number into its respective character. Its counterpart (string.byte
) does the opposite; it turns a character into its ASCII number.
Why just why make it so complicated, use a for loop and a table of letters like bro…
Your solution to this exploit script is not to rename scripts. Your solution should be creating an anticheat to counter all teleport/walkspeed scripts. You can do this by every heartbeat checking their current position while also their previous heartbeat position and seeing if they made too much distance.
Lol this is over a year old bro
very late on this, but here. I made this script a while ago to random gen a line of string then send it via a discord webhook.
local HttpService = game:GetService("HttpService")
local DISCORD_WEBHOOK_URL = ""
local symbols = {"!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "=", "{", "}", "[", "]", ";", ":", "'", "\"", ",", "<", ">", ".", "/", "?", "`", "~"}
local letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
local numbers = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
local function generateCode(length)
local code = ""
for i = 1, length do
local randomIndex = math.random(1, 3)
if randomIndex == 1 then
code = code .. symbols[math.random(1, #symbols)]
elseif randomIndex == 2 then
code = code .. letters[math.random(1, #letters)]
else
code = code .. numbers[math.random(1, #numbers)]
end
end
return code
end
local code = generateCode(12)
print("Generated code: " .. code)
local generatedText = script.Parent
generatedText.Text = code
local postData = HttpService:JSONEncode({content = "New code generated: " .. code })
local success, result = pcall(function()
HttpService:PostAsync(DISCORD_WEBHOOK_URL, postData)
end)
if not success then
warn("HttpService request failed: " .. tostring(result))
end
HttpService has a function called “GenerateGUID” which generated a random string of characters.
Naming items randomly generated strings isn’t going to help with preventing exploiters accessing them; they use the Explorer thing to see everything that’s in your game, except ServerScriptService and a few others.
Just focus on never trusting the client. Look at any RemoteEvents/Functions that send from Client > Server, and see if those values can be changed. Keep in mind that the player
variable CANNOT be changed, so only focus on the parameters that are being sent in the remote, and not the player.
Someone already mentioned this. You just bumped a year old post for no reason.