- What do you want to achieve? Keep it simple and clear!
I want to make the highlights visible and not bugged. - What is the issue? Include screenshots / videos if possible!
In the last seconds of the ability, highlights aren’t visible, even though they are still a child in the hexagon. - What solutions have you tried so far? Did you look for solutions on the Creator Hub?
I tried fixing it with the roblox ai assistand and chatgpt but nothing worked.
Here is the entire script, the highlights are added in the elseif “eraser” part
local collectionservice = game:GetService("CollectionService")
local replicatedstorage = game.ReplicatedStorage
local serverstorage = game:GetService("ServerStorage")
local availableHexagons = game.Workspace:WaitForChild("AvaibleHexagons")
local coinrushDebounce = {}
local eraserDebounce = {}
-- Fade function
local function Fade(hexagon,step)
hexagon.CanTouch = false
for i = 1, step do
hexagon.Transparency = i / step
wait(0.01)
end
if hexagon:FindFirstChildOfClass("Highlight") then
for i, highlight in hexagon:GetChildren() do
if highlight:IsA("Highlight") then
highlight:Destroy()
end
end
end
end
-- One-time listener for eraser activation
replicatedstorage.HexagonEvent.Event:Connect(function(ability, plr)
if ability == "Eraser" then
for _, hexagon in pairs(availableHexagons:GetChildren()) do
local highlight = hexagon:FindFirstChildOfClass("Highlight")
if highlight and hexagon.CanCollide == true then
if highlight.Name == plr.Name then
task.spawn(function()
print("should work")
Fade(hexagon,20)
hexagon.CanCollide = false
hexagon.Transparency = 1
highlight:Destroy()
end)
end
end
end
end
end)
-- Main game start logic
replicatedstorage.RoundSystemValues:WaitForChild("GameIsActive"):GetPropertyChangedSignal("Value"):Connect(function()
if replicatedstorage.RoundSystemValues.GameIsActive.Value == true then
for _, hexagon in pairs(availableHexagons:GetChildren()) do
local debounce = false
replicatedstorage.LocalAbilityEvent.OnServerEvent:Connect(function(plr, v)
if v:IsA("MeshPart") then
v.Parent = availableHexagons
v.Transparency = 0
end
end)
hexagon.Touched:Connect(function(hit)
local Shield = hit.Parent:FindFirstChild("ShieldHighlight")
local Coinrush = hit.Parent:FindFirstChild("CoinrushHighlight")
local Eraser = hit.Parent:FindFirstChild("EraserHighlight")
if Shield then
if not debounce then
debounce = true
wait(1)
debounce = false
end
elseif Coinrush and not coinrushDebounce[hexagon] then
coinrushDebounce[hexagon] = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and player:FindFirstChild("leaderstats") then
player.leaderstats.HexaCoins.Value += 1
end
Fade(hexagon,20)
hexagon.CanCollide = false
hexagon.Transparency = 1
task.delay(1, function()
coinrushDebounce[hexagon] = nil
end)
elseif Eraser then
local unlockTimers = {} -- tracks whether or not a player has a timer
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
local highlight = hexagon:FindFirstChildOfClass("Highlight")
if not highlight or highlight.Name ~= player.Name then
-- delete the old highlight if it's not yours
if highlight then
print("Destroying old highlight for hexagon: " .. hexagon.Name)
highlight:Destroy()
end
local newHighlight = Instance.new("Highlight")
newHighlight.Name = player.Name
newHighlight.FillTransparency = 0.5
newHighlight.OutlineTransparency = 1
newHighlight.Adornee = hexagon
newHighlight.Parent = hexagon
print("Created new highlight for hexagon: " .. hexagon.Name .. " by player: " .. player.Name)
-- Block destruction until allowed
hexagon:SetAttribute("CanBeDestroyedBy", false)
-- If this is the first time, set a timer for the player
if not unlockTimers[player.UserId] then
unlockTimers[player.UserId] = true
task.wait(5)
task.spawn(function()
for _, hx in pairs(availableHexagons:GetChildren()) do
local h = hx:FindFirstChildOfClass("Highlight")
if h and h.Name == player.Name then
hx:SetAttribute("CanBeDestroyedBy", player.UserId)
print("CAN BE DESTROYED: " .. hx.Name .. " by " .. player.Name)
end
end
unlockTimers[player.UserId] = nil
end)
end
elseif hexagon:GetAttribute("CanBeDestroyedBy") == player.UserId and highlight.Name == player.Name then
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
if hrp and (hrp.Position - hexagon.Position).Magnitude < (hexagon.Size.X / 2 + 2) then
hrp.Velocity = Vector3.new(0, 15, 0)
end
Fade(hexagon,20)
hexagon.CanCollide = false
hexagon.Transparency = 1
hexagon:SetAttribute("CanBeDestroyedBy", nil)
highlight:Destroy()
print("Destroyed highlight after hexagon destruction: " .. hexagon.Name)
end
elseif hit.Name == "MainPart" then
if debounce == false then
debounce = true
-- Additional check to see if the parent exists
local bombModel = hit.Parent
local HitSphere = replicatedstorage.AbilityAssets.Bomb.HitSphere:Clone()
print(hit.Name)
task.wait(0.1)
bombModel.MainPart.CanTouch = false
HitSphere.Parent = bombModel.MainPart
HitSphere.CFrame = bombModel.MainPart.CFrame
task.wait(0.1)
hit.Anchored = true
HitSphere.Anchored = true
bombModel.MainPart.Attachment.Debris:Emit(12)
bombModel.MainPart.Attachment.Main:Emit(200)
bombModel.MainPart.Explosion:Play()
Fade(bombModel.MainPart,10)
task.wait(0.1)
Fade(hexagon,20)
hexagon.CanCollide = false
hexagon.Transparency = 1
task.wait(0.5)
bombModel:Destroy()
HitSphere:Destroy()
debounce = false
end
else
if not debounce then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local highlight = hexagon:FindFirstChildOfClass("Highlight")
local canDestroy = hexagon:GetAttribute("CanBeDestroyedBy")
if highlight then
-- Highlight exists: only owner can destroy after allowed time
if canDestroy == plr.UserId and highlight.Name == plr.Name then
debounce = true
Fade(hexagon, 20)
hexagon.CanCollide = false
hexagon.Transparency = 1
highlight:Destroy()
end
else
-- No highlight: allow anyone to destroy
debounce = true
Fade(hexagon, 20)
hexagon.CanCollide = false
hexagon.Transparency = 1
end
end
end
end)
end
end
end)
I attached a video too, so you can see the problem better.