This is a part of a character selection script,
When a player clicks the character it shows the preview but if the character he clicked name is not the one matching it directly puts him back to ReplicatedStorage but if it matches it brings the preview in worksapce I managed to make the first part which if it matches but if it doesn’t match how do i make it detect the unmatched char names that is no longer in the file loop but went to workspace?
Script:
for _, v in Characters:GetDescendants() do
if v:IsA("ViewportFrame") then
v.TextButton.Activated:Connect(function() -- When character is clicked
VampSpawn.Visible = true
VampOutfit.Visible = true
SelectedChar = v
for i, v1 in pairs(ReplicatedStorage.VampirePreview:GetChildren()) do
local CharPreview = v1
if v1.Name == SelectedChar.Name then
print("Bringing")
CharPreview.Parent = workspace
CharPreview.PrimaryPart.CFrame = CFrame.new(game.Workspace.CharacterSelection.Fp.Position)
CharPreview.PrimaryPart.CFrame = CFrame.lookAt(game.Workspace.CharacterSelection.Fp.Position, game.Workspace.CharacterSelection.Ep.Position)
end
end