local uis = game:GetService("UserInputService")
local upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local lowerCase = "abcdefghijklmnopqrstuvwxyz"
local numbers = "0123456789"
local symbols = "!@#$%&()*+-,./\:;<=>?^[]{}"
local characterSet = upperCase .. lowerCase .. numbers .. symbols
local keyLength = 32
local output = ""
leftClick = uis.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local NewRemote = Instance.new("RemoteEvent")
NewRemote.Parent = game.ReplicatedStorage
for i = 1, keyLength do
local rand = math.random(#characterSet)
NewRemote.Name = output .. string.sub(characterSet, rand, rand)
end
end
end)
It’s because you’re setting the Name without changing your output variable. It looks like it’s being set 32 times, and only the last character will be added (all the other times, it’ll be replaced).
What you want to do instead is update your output variable at each loop (this is where you’re currently setting NewRemote.Name) and only set the Name after your loop runs. That way, the new character will be stored each iteration & you’ll take the entire thing:
local output= ""
for i = 1, keyLength do
local rand = math.random(#characterSet)
output = output .. string.sub(characterSet, rand, rand)
end
NewRemote.Name = output
Note - I also moved the initial setting of output to just before the for loop; otherwise your output string will constantly get bigger (because previous runs will still be stored inside its value)
2 Likes