Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Highlights not working properly in roblox studio?

Asked by
2mania 14
1 year ago

Im making a power in my game where you can basically use esp through walls and im using highlights to highlight the root part of the player and it works fine for most people but not everyone i checked and they do have the highlight in them it just dosnt work for some reason is there a way to fix it?

local Players = game:GetService("Players"):GetChildren()
local RunService = game:GetService("RunService")
local highlight = Instance.new("Highlight")
highlight.Name = "Highlight"


for i, v in pairs(Players) do
    repeat wait() until v.Character
    if not v.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("Highlight") then
        local highlightclone = highlight:Clone()
        highlightclone.Enabled = true
        highlightclone.Adornee = v.Character
        highlightclone.Parent = v.Character:FindFirstChild("HumanoidRootPart")
        highlightclone.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
        highlightclone.FillTransparency = 0
        highlightclone.FillColor = Color3.new(0.094117, 0.745098, 1)
        highlightclone.OutlineTransparency = 1
    end
end

game.Players.PlayerAdded:Connect(function(player)
    repeat wait() until player.Character
    if not player.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("Highlight") then
        local highlightclone = highlight:Clone()
        highlightclone.Enabled = true
        highlightclone.Adornee = player.Character
        highlightclone.Parent = player.Character:FindFirstChild("HumanoidRootPart")
        highlightclone.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
        highlightclone.FillTransparency = 0
        highlightclone.FillColor = Color3.new(0.094117, 0.745098, 1)
        highlightclone.OutlineTransparency = 1
    end
end)

game.Players.PlayerRemoving:Connect(function(playerremoved)
    playerremoved.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("Highlight"):Destroy()
end)


RunService.Heartbeat:Connect(function()
    for i, v in pairs(Players) do
        repeat wait() until v.Character
        if not v.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("Highlight") then
            local highlightclone = highlight:Clone()
            highlightclone.Enabled = true
            highlightclone.Adornee = v.Character
            highlightclone.Parent = v.Character:FindFirstChild("HumanoidRootPart")
            highlightclone.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
            highlightclone.FillTransparency = 0
            highlightclone.FillColor = Color3.new(0.094117, 0.745098, 1)
            highlightclone.OutlineTransparency = 1
        end
    end
end)

Answer this question