Highlight effect not applying when cloning a script

Hello
I’m trying to make a radar system.
In this system I’m taking a ring out of replicated storage and cloning it - with it’s scripts
however when it gets cloned it expands like I have scripted it to, but it doesn’t use the script that adds a highlight to the players when they come in-contact with the ring

Radar Creator
local loading = script.Parent.TextLabel
local p = game.Players.LocalPlayer
local hrp = p.Character.HumanoidRootPart
local mouse = p:GetMouse()
local storage = game.ReplicatedStorage
local active = false

mouse.KeyDown:Connect(function(key)
	if key == "r" then
		if not active then
			active = true
			loading.Text = "Radar Not Ready: 15"
			
			local ring = storage.ring:Clone()
			ring.Parent = workspace
			ring.CFrame = hrp.CFrame * CFrame.Angles(math.rad(90), 0, 0)
			ring.Transparency = 1 
			ring.CanTouch = true
			
			local smoothness = 25 
			local explosionRadius = 150
			for i = 1, smoothness do 
				local alpha = (smoothness-i)/smoothness
				local a = i / smoothness
				local size = explosionRadius * a
				ring.Size = Vector3.new(size * 1.5, 0.285, size * 1.5)
				ring.Orientation = Vector3.new(0, 90, 0)
				ring.Transparency = alpha
				game:GetService('RunService').RenderStepped:Wait()
			end
			local fadeAwaySmoothness = math.ceil(smoothness * 1.5)
			local explosionRadius2 = 50
			for i = 1, fadeAwaySmoothness do 
				local a = i / fadeAwaySmoothness
				local size = explosionRadius + a * explosionRadius2
				ring.Size = Vector3.new(size * 1.5, 0.285, size * 1.5)
				ring.Transparency = a
				game:GetService('RunService').RenderStepped:Wait()
			end
			
			ring:Destroy()
			wait(1)
			loading.Text = "Radar Not Ready: 14"
			wait(1)
			loading.Text = "Radar Not Ready: 13"
			wait(1)
			loading.Text = "Radar Not Ready: 12"
			wait(1)
			loading.Text = "Radar Not Ready: 11"
			wait(1)
			loading.Text = "Radar Not Ready: 10"
			wait(1)
			loading.Text = "Radar Not Ready: 9"
			wait(1)
			loading.Text = "Radar Not Ready: 8"
			wait(1)
			loading.Text = "Radar Not Ready: 7"
			wait(1)
			loading.Text = "Radar Not Ready: 6"
			wait(1)
			loading.Text = "Radar Not Ready: 5"
			wait(1)
			loading.Text = "Radar Not Ready: 4"
			wait(1)
			loading.Text = "Radar Not Ready: 3"
			wait(1)
			loading.Text = "Radar Not Ready: 2"
			wait(1)
			loading.Text = "Radar Not Ready: 1"
			wait(1)
			active = false
			loading.Text = "Press R To Activate Radar"
		end
	end
end)


mesh / Ring script - the duplicated one

local ring = script.Parent

local function giveHighlightToHumanoid(hit)
local character = hit.Parent
– Humanoid highlight logic
if character and character:FindFirstChild(“Humanoid”) then
if not character:FindFirstChild(“Highlight”) then
local highlight = Instance.new(“Highlight”)
highlight.Name = “Highlight”
highlight.Parent = character
wait(1)
highlight:Destroy()
end
end

-- Highlight Rig Model (for testing)
if character and character:IsA("Model") and workspace:FindFirstChild(character.Name) then
    if not character:FindFirstChild("Highlight") then
        local highlight = Instance.new("Highlight")
        highlight.Name = "Highlight"
        highlight.Parent = character
        wait(1)
        highlight:Destroy()
    end
end

end

ring.Touched:Connect(giveHighlightToHumanoid)

LMK - if anyone got any ideas on how to go about this

1 Like

yo i think i know what’s going on

if the script inside the ring is a LocalScript, it probably isn’t running after you clone it into the workspace. local scripts only work in certain spots like StarterPlayerScripts, the player’s character, gui, etc. once it’s in workspace, roblox just ignores it.

that would explain why the ring itself expands fine (since that’s handled in your main script), but the touch/highlight part never happens — because that script isn’t actually running.

you could move the highlight code to a regular Script instead (on the server), or just handle the highlight stuff directly in your main radar script. either way, i don’t think that inner script is doing anything right now after the clone.

2 Likes

yo
it was already a normal script.
where do you think I should move it?