You will be given a Luau script (that has been decompiled). You will rename the…
- User
System: You will be given a Luau script (that has been decompiled). You will rename the variables and functions to sound better, make the script more coherent, and add comments to areas of the script. Return the fixed script without adding ``` as we handle that. If no script has been given, do not produce any output. Do not respond with anything but the script User: -- Decompiled with Konstant V2.1, a fast Luau decompiler made in Luau by plusgiant5 (https://discord.gg/wyButjTMhM) -- Decompiled on 2024-11-11 15:00:26 -- Luau version 6, Types version 3 -- Time taken: 0.004760 seconds
local GuiMain_upvr = Instance.new("GuiMain") GuiMain_upvr.Name = "TacticalVisorMain" local var2_upvw allycolor = BrickColor.new("Navy blue") -- Setting global enemycolor = BrickColor.new("Really red") -- Setting global unkowncolor = BrickColor.new("Mid gray") -- Setting global objectcolor = BrickColor.new("Lime green") -- Setting global local Frame_upvr = Instance.new("Frame") Frame_upvr.Name = "Visor" Frame_upvr.Position = UDim2.new(0, 0, 0, 0) Frame_upvr.Size = UDim2.new(0, 0, 0, 0) Frame_upvr.BackgroundColor = BrickColor.new("Bright orange") Frame_upvr.BorderColor = Frame_upvr.BackgroundColor Frame_upvr.Transparency = 1 Frame_upvr.ZIndex = 1 Frame_upvr.SizeConstraint = "RelativeXX" Frame_upvr.Parent = GuiMain_upvr local var4_upvw function onMove(arg1) -- Line 29 --[[ Upvalues[1]: [1]: GuiMain_upvr (readonly) ]] if arg1.Target == nil then else if getHumanoid(lastParent(arg1.Target)) then if GuiMain_upvr:findFirstChild("Character Display Data") then GuiMain_upvr["Character Display Data"]:remove() end displayData(lastParent(arg1.Target)) return end if GuiMain_upvr:findFirstChild("Character Display Data") then game:getService("Debris"):addItem(GuiMain_upvr["Character Display Data"], 3) end end end function PlayerCharacter(arg1) -- Line 44 for _, v in pairs(game.Players:getChildren()) do if v.Character == arg1 then return v end end return nil end function displayData(arg1) -- Line 53 --[[ Upvalues[1]: [1]: GuiMain_upvr (readonly) ]] if GuiMain_upvr:findFirstChild("Character Display Data") then else local clone_3 = script.DataTemplate:clone() local getHumanoid_result1 = getHumanoid(arg1) clone_3.Name = "Character Display Data" if PlayerCharacter(arg1) ~= nil then local PlayerCharacter_result1 = PlayerCharacter(arg1) clone_3.CharPicture.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..PlayerCharacter_result1.Name..'&'..PlayerCharacter_result1.userId clone_3.CharHealth.Text = "Health: "..math.ceil(getHumanoid_result1.Health)..'/'..getHumanoid_result1.MaxHealth clone_3.CharName.Text = arg1.Name if PlayerCharacter_result1.Neutral then clone_3.CharTeam.Text = "Neutral" end clone_3.CharType.Text = "Player/"..getHumanoid_result1.Name else clone_3.CharPicture.Image = "" clone_3.CharHealth.Text = "Health: "..math.ceil(getHumanoid_result1.Health)..'/'..getHumanoid_result1.MaxHealth clone_3.CharName.Text = arg1.Name clone_3.CharType.Text = "Type: "..getHumanoid_result1.Name end clone_3.Parent = GuiMain_upvr end end function isPartish(arg1) -- Line 76 for _, v_2 in pairs({"Part", "Seat", "VehicleSeat", "Flagstand", "SpawnPoint"}) do if string.lower(v_2) == string.lower(arg1.className) then return true end end return false end function getHumanoid(arg1) -- Line 86 for _, v_3 in pairs(arg1:getChildren()) do if v_3.className == "Humanoid" then return v_3 end end end function isInTable(arg1, arg2) -- Line 94 for _, v_4 in pairs(arg2) do if arg1 == v_4 then return true end end return false end function lastParent(arg1) -- Line 103 local var29 = arg1 local Parent = var29.Parent while true do if Parent == workspace or Parent == game.Lighting or Parent == nil then return var29 end end end function selectAllPartsOfHuman(arg1, arg2) -- Line 116 --[[ Upvalues[1]: [1]: Frame_upvr (readonly) ]] -- KONSTANTERROR: [0] 1. Error Block 1 start (CF ANALYSIS FAILED) -- KONSTANTERROR: [0] 1. Error Block 1 end (CF ANALYSIS FAILED) -- KONSTANTERROR: [4] 3. Error Block 2 start (CF ANALYSIS FAILED) -- KONSTANTERROR: [4] 3. Error Block 2 end (CF ANALYSIS FAILED) -- KONSTANTERROR: [8] 5. Error Block 3 start (CF ANALYSIS FAILED) -- KONSTANTERROR: [8] 5. Error Block 3 end (CF ANALYSIS FAILED) -- KONSTANTERROR: [12] 7. Error Block 32 start (CF ANALYSIS FAILED) local SelectionBox = Instance.new("SelectionBox") SelectionBox.Adornee = arg1 SelectionBox.Transparency = 1 if arg2 ~= nil then if arg2.TeamColor == game.Players.LocalPlayer.TeamColor and arg2.Neutral == false then SelectionBox.Color = allycolor elseif arg2.TeamColor ~= game.Players.LocalPlayer.TeamColor and arg2.Neutral == false then SelectionBox.Color = enemycolor elseif arg2.Neutral then SelectionBox.Color = unkowncolor -- KONSTANTWARNING: GOTO [77] #43 end else SelectionBox.Color = unkowncolor end -- KONSTANTERROR: [12] 7. Error Block 32 end (CF ANALYSIS FAILED) end local tbl_upvr_2 = {} local tbl_upvr = {} function scanForHumanoids(arg1) -- Line 148 --[[ Upvalues[3]: [1]: tbl_upvr_2 (readonly) [2]: tbl_upvr (readonly) [3]: Frame_upvr (readonly) ]] -- KONSTANTERROR: [0] 1. Error Block 1 start (CF ANALYSIS FAILED) -- KONSTANTERROR: [0] 1. Error Block 1 end (CF ANALYSIS FAILED) -- KONSTANTERROR: [23] 14. Error Block 4 start (CF ANALYSIS FAILED) table.insert(tbl_upvr_2, arg1.Parent) selectAllPartsOfHuman(arg1.Parent, PlayerCharacter(arg1.Parent)) arg1.Parent.ChildAdded:connect(function() -- Line 154 --[[ Upvalues[1]: [1]: arg1 (readonly) ]] selectAllPartsOfHuman(arg1.Parent) end) do return end -- KONSTANTERROR: [23] 14. Error Block 4 end (CF ANALYSIS FAILED) -- KONSTANTERROR: [51] 32. Error Block 15 start (CF ANALYSIS FAILED) if isPartish(arg1) and arg1.Parent ~= game.Players.LocalPlayer.Character and arg1.Parent.Parent ~= game.Players.LocalPlayer.Character and getHumanoid(lastParent(arg1)) == nil then table.insert(tbl_upvr, arg1) local SelectionBox_upvr = Instance.new("SelectionBox") SelectionBox_upvr.Adornee = arg1 SelectionBox_upvr.Transparency = 1 SelectionBox_upvr.Color = objectcolor SelectionBox_upvr.Name = "ObjSelection"..arg1.Name SelectionBox_upvr.Parent = Frame_upvr arg1.AncestryChanged:connect(function() -- Line 166 --[[ Upvalues[2]: [1]: arg1 (readonly) [2]: SelectionBox_upvr (readonly) ]] if arg1.Parent == nil or lastParent(arg1).Parent ~= workspace then SelectionBox_upvr:remove() end end) return end SelectionBox_upvr = pairs(arg1:getChildren()) for _, v_5 in pairs(arg1:getChildren()) do scanForHumanoids(v_5) end -- KONSTANTERROR: [51] 32. Error Block 15 end (CF ANALYSIS FAILED) end function onKeyDown(arg1, arg2) -- Line 179 --[[ Upvalues[1]: [1]: var4_upvw (read and write) ]] local any_lower_result1 = arg1:lower() if any_lower_result1 == '\b' and var4_upvw.Character ~= nil and var4_upvw.Character:findFirstChild("Head") ~= nil then local clone_2 = script.Parent:clone() clone_2.Active = true clone_2.Parent = workspace onDeselected(arg2) script.Parent:remove() end if any_lower_result1 == 'e' then onDeselected(arg2) end end local var44_upvw = false function onSelected(arg1) -- Line 195 --[[ Upvalues[4]: [1]: var4_upvw (read and write) [2]: GuiMain_upvr (readonly) [3]: var44_upvw (read and write) [4]: var2_upvw (read and write) ]] var4_upvw = game.Players.LocalPlayer arg1.KeyDown:connect(function(arg1_2) -- Line 197 --[[ Upvalues[1]: [1]: arg1 (readonly) ]] onKeyDown(arg1_2, arg1) end) arg1.Move:connect(function() -- Line 198 --[[ Upvalues[1]: [1]: arg1 (readonly) ]] onMove(arg1) end) if var4_upvw.Character ~= nil and GuiMain_upvr.Parent == nil then local clone = script.ColorMessage:clone() clone.Parent = GuiMain_upvr game:getService("Debris"):addItem(clone, 8) end if var4_upvw:findFirstChild("PlayerGui") == nil then Instance.new("PlayerGui").Parent = var4_upvw end GuiMain_upvr.Parent = var4_upvw.PlayerGui if not var44_upvw then scanForHumanoids(workspace) var44_upvw = true end var2_upvw = workspace.ChildAdded:connect(function(arg1_3) -- Line 212 scanForHumanoids(arg1_3) end) end script.Parent.Equipped:connect(onSelected) function onDeselected(arg1) -- Line 216 --[[ Upvalues[2]: [1]: GuiMain_upvr (readonly) [2]: var2_upvw (read and write) ]] GuiMain_upvr.Parent = nil if var2_upvw ~= nil then var2_upvw:disconnect() var2_upvw = nil end end script.Parent.Unequipped:connect(onDeselected) Assistant:
- Assistant
local TacticalVisorGui = Instance.new("GuiMain") TacticalVisorGui.Name = "TacticalVisorMain" local itemConnection local allyColor = BrickColor.new("Navy blue") local enemyColor = BrickColor.new("Really red") local unknownColor = BrickColor.new("Mid gray") local objectColor = BrickColor.new("Lime green") local visorFrame = Instance.new("Frame") visorFrame.Name = "Visor" visorFrame.Position = UDim2.new(0, 0, 0, 0) visorFrame.Size = UDim2.new(0, 0, 0, 0) visorFrame.BackgroundColor = BrickColor.new("Bright orange") visorFrame.BorderColor = visorFrame.BackgroundColor visorFrame.Transparency = 1 visorFrame.ZIndex = 1 visorFrame.SizeConstraint = "RelativeXX" visorFrame.Parent = TacticalVisorGui local playerInstance -- Function triggered on movement function onPlayerMove(event) if event.Target == nil then return end local targetPart = lastParent(event.Target) if getHumanoid(targetPart) then if TacticalVisorGui:FindFirstChild("Character Display Data") then TacticalVisorGui["Character Display Data"]:Destroy() end displayCharacterData(targetPart) else if TacticalVisorGui:FindFirstChild("Character Display Data") then game:GetService("Debris"):AddItem(TacticalVisorGui["Character Display Data"], 3) end end end -- Function to retrieve the player object associated with a character function getPlayerFromCharacter(character) for _, player in pairs(game.Players:GetChildren()) do if player.Character == character then return player end end return nil end -- Function to display character data on GUI function displayCharacterData(character) if not TacticalVisorGui:FindFirstChild("Character Display Data") then local dataClone = script.DataTemplate:Clone() local humanoid = getHumanoid(character) dataClone.Name = "Character Display Data" if getPlayerFromCharacter(character) then local player = getPlayerFromCharacter(character) dataClone.CharPicture.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=" .. player.Name .. '&' .. player.UserId dataClone.CharHealth.Text = "Health: " .. math.ceil(humanoid.Health) .. '/' .. humanoid.MaxHealth dataClone.CharName.Text = character.Name dataClone.CharTeam.Text = player.Neutral and "Neutral" or player.Team.Name dataClone.CharType.Text = "Player/" .. humanoid.Name else dataClone.CharPicture.Image = "" dataClone.CharHealth.Text = "Health: " .. math.ceil(humanoid.Health) .. '/' .. humanoid.MaxHealth dataClone.CharName.Text = character.Name dataClone.CharType.Text = "Type: " .. humanoid.Name end dataClone.Parent = TacticalVisorGui end end -- Check if argument is a part function isPart(arg) for _, partType in pairs({"Part", "Seat", "VehicleSeat", "Flagstand", "SpawnPoint"}) do if string.lower(partType) == string.lower(arg.className) then return true end end return false end -- Retrieve humanoid object from model function getHumanoid(model) for _, child in pairs(model:GetChildren()) do if child.className == "Humanoid" then return child end end end -- Check if a value is present in a table function isInTable(value, tbl) for _, item in pairs(tbl) do if value == item then return true end end return false end -- Retrieve the ultimate parent from the hierarchy function lastParent(item) local current = item local parent = current.Parent while parent and parent ~= workspace and parent ~= game.Lighting do current = parent parent = current.Parent end return current end -- Select and highlight all parts belonging to a specific humanoid function selectAllHumanParts(part, character) local selectionBox = Instance.new("SelectionBox") selectionBox.Adornee = part selectionBox.Transparency = 1 if character then if character.TeamColor == game.Players.LocalPlayer.TeamColor and not character.Neutral then selectionBox.Color = allyColor elseif character.TeamColor ~= game.Players.LocalPlayer.TeamColor and not character.Neutral then selectionBox.Color = enemyColor else selectionBox.Color = unknownColor end else selectionBox.Color = unknownColor end end local encounteredParts = {} local partList = {} -- Recursively scan for humanoids in the workspace function scanWorkspaceForHumanoids(workspaceItem) table.insert(encounteredParts, workspaceItem.Parent) selectAllHumanParts(workspaceItem.Parent, getPlayerFromCharacter(workspaceItem.Parent)) workspaceItem.Parent.ChildAdded:Connect(function() selectAllHumanParts(workspaceItem.Parent) end) if isPart(workspaceItem) and not workspaceItem:IsDescendantOf(game.Players.LocalPlayer.Character) and not getHumanoid(lastParent(workspaceItem)) then table.insert(partList, workspaceItem) local selectionBox = Instance.new("SelectionBox") selectionBox.Adornee = workspaceItem selectionBox.Transparency = 1 selectionBox.Color = objectColor selectionBox.Name = "ObjSelection" .. workspaceItem.Name selectionBox.Parent = visorFrame workspaceItem.AncestryChanged:Connect(function() if not workspaceItem.Parent or not workspaceItem:IsDescendantOf(workspace) then selectionBox:Destroy() end end) end for _, child in pairs(workspaceItem:GetChildren()) do scanWorkspaceForHumanoids(child) end end -- Handle key down events function handleKeyDown(key, event) local keyLower = key:lower() if keyLower == '\b' and playerInstance.Character and playerInstance.Character:FindFirstChild("Head") then local clone = script.Parent:Clone() clone.Active = true clone.Parent = workspace handleDeselection(event) script.Parent:Destroy() end if keyLower == 'e' then handleDeselection(event) end end local didInitialScan = false -- Function to handle selection of tool function handleSelection(event) playerInstance = game.Players.LocalPlayer event.KeyDown:Connect(function(key) handleKeyDown(key, event) end) event.Move:Connect(function() onPlayerMove(event) end) if playerInstance.Character and not TacticalVisorGui.Parent then local colorMessage = script.ColorMessage:Clone() colorMessage.Parent = TacticalVisorGui game:GetService("Debris"):AddItem(colorMessage, 8) end if not playerInstance:FindFirstChild("PlayerGui") then Instance.new("PlayerGui").Parent = playerInstance end TacticalVisorGui.Parent = playerInstance.PlayerGui if not didInitialScan then scanWorkspaceForHumanoids(workspace) didInitialScan = true end itemConnection = workspace.ChildAdded:Connect(scanWorkspaceForHumanoids) end script.Parent.Equipped:Connect(handleSelection) -- Function to handle tool deselection function handleDeselection() TacticalVisorGui.Parent = nil if itemConnection then itemConnection:Disconnect() itemConnection = nil end end script.Parent.Unequipped:Connect(handleDeselection)