Highlight's property changing depending on if attachment found in root or not

hello guys, so my goal is to make the highlight change colors/transparency when an attachment is found in the humanoidrootpart and changes back when its not found (it should only work if a certain attachment is found). i tried something but its kinda weird since i suck at scripting but here is what i tried (it doesnt work)

local script (in attachment)

local player = game.Players.LocalPlayer
local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
local rs = game.ReplicatedStorage
local fillTransparency = 0.5
local fillColor = Color3.fromRGB(9, 70, 0)
local outlineColor = Color3.fromRGB(9, 70, 0)
local outlineTransparency = 0

root.Changed:Connect(function(player, fillTransparency, fillColor, outlineColor, outlineTransparency)
	rs.Remotes.HighlightChange:FireServer(fillTransparency, fillColor, outlineColor, outlineTransparency)
end)

server script (in serverscriptservice)

local rs = game.ReplicatedStorage
local highlight = game.ReplicatedStorage.Highlight:Clone()

--game.Players.PlayerAdded:Connect(function(player)
	--player.CharacterAdded:Connect(function(char)
		--highlight.Parent = char                             --this part just spawns the highlight upon joining
		--highlight.FillTransparency = 1
		--highlight.OutlineTransparency = 1
	--end)
--end)

rs.Remotes.HighlightChange.OnServerEvent:Connect(function(player, fillTransparency, fillColor, outlineColor, outlineTransparency)
	print(player..fillTransparency..fillColor..outlineColor..outlineTransparency)
	if player.Character:WaitForChild("HumanoidRootPart"):FindFirstChild("Aura") then --"Aura" is the attachment im talking about
		highlight.FillTransparency = fillTransparency
		highlight.OutlineTransparency = outlineTransparency
		highlight.FillColor = fillColor
		highlight.OutlineColor = outlineColor
	else
		highlight.FillTransparency = 1
		highlight.OutlineTransparency = 1
	end
end)

i dont get any errors so idk what im doing wrong, but thanks for any help.

1 Like

It looks like you are trying to apply attributes directly to the highlight you cloned when the player joined.

But that clone is long gone as is now part of a player.

To apply the attributes you need to find the Highlight inside the player triggered the event. Something like so:

Player.Character.Highlight.FillTransparency = fillTransparency

1 Like

i forgot i about this one but it worked thanks :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.