I’m trying to make a hint system for my guessing game but I am having trouble generating the hint.
I’m trying to convert RainbowDash to R____o____h but I can’t figure out how I would replace the inside characters with underscores.
I can get the first, middle, and last character already.
local characters = workspace.Map.Characters:GetDescendants()
local hintLabel = script.Parent.HintLabel
local player = game.Players.LocalPlayer
local stage = player.leaderstats.Stage
function generateHint(stageValue)
for _, object in ipairs(characters) do
if object:IsA("Model") then
local pony = object.Name:split("_")
local ponyName = pony[1] -- example: RainbowDash
local ponyStage = tonumber(pony[2])
if stageValue ~= ponyStage then continue end
-- Get first, middle, and last character from name and replace others with spaces
local firstCharacter = string.sub(ponyName, 1, 1) -- example: R
local lastCharacter = string.sub(ponyName, string.len(ponyName), string.len(ponyName)) -- example: h
local middleCharacter = string.sub(ponyName, tonumber(math.round(string.len(ponyName) / 2)), tonumber(math.round(string.len(ponyName) / 2))) -- example: o
print(firstCharacter.." "..middleCharacter.." "..lastCharacter) -- example: R o h
local generatedHint = -- help here
print(generatedHint)
end
end
end
stage:GetPropertyChangedSignal("Value"):Connect(function()
generateHint(stage.Value)
end)