local a=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local D=game:GetService("\067\111\108\108\101\099\116\105\111\110\083\101\114\118\105\099\101")local r=game:GetService("\080\108\097\121\101\114\115")local s=D:GetTagged("\076\105\103\104\116\117\112\066\117\116\116\111\110")local Y={}local N={}for a,D in pairs(s)do Y[D]={active=false}end local function o(a)a.CharacterAdded:Connect(function(D)repeat task.wait(.2)until D and(D.PrimaryPart and D.Humanoid)N[a]=D end)a.CharacterRemoving:Connect(function(D)N[a]=nil end)end r.PlayerAdded:Connect(o)for a,D in pairs(r:GetChildren())do o(D)end while true do local a=D:GetTagged("\076\105\103\104\116\117\112\066\117\116\116\111\110")for a,D in pairs(a)do if Y[D]==nil then Y[D]={active=false}end end for a,D in pairs(Y)do D.active=false end for D,r in pairs(N)do if r and(r.PrimaryPart and r.Humanoid)then local D=RaycastParams.new()D.FilterDescendantsInstances=a D.FilterType=Enum.RaycastFilterType.Whitelist local s=workspace:Raycast(r.PrimaryPart.Position,Vector3.new(0,-6,0),D)if s and s.Instance then if Y[s.Instance]then Y[s.Instance].active=true end end end end task.wait()for a,D in pairs(Y)do if D.active then a.Material=Enum.Material.Neon else a.Material=Enum.Material.Plastic end end end

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")

local taggedButtons = CollectionService:GetTagged("LightupButton")

local buttons = {}
local characters = {}

for _, button in pairs(taggedButtons) do
	buttons[button] = {
		active = false
	}
end


local function onPlayerAdded(player)
	player.CharacterAdded:Connect(function(character)
		repeat task.wait(.2) until character and character.PrimaryPart and character.Humanoid

		characters[player] = character
	end)
	player.CharacterRemoving:Connect(function(character)
		characters[player] = nil
	end)
end

Players.PlayerAdded:Connect(onPlayerAdded)

for _, player in pairs(Players:GetChildren()) do
	onPlayerAdded(player)
end


while true do
	local taggedButtons = CollectionService:GetTagged("LightupButton")

	for _, button in pairs(taggedButtons) do
		if buttons[button] == nil then
			buttons[button] = {
				active = false
			}
		end
	end
	
	for _, button in pairs(buttons) do
		button.active = false
	end
	
	for player, character in pairs(characters) do
		if character and character.PrimaryPart and character.Humanoid then
			local raycastParams = RaycastParams.new()
			raycastParams.FilterDescendantsInstances = taggedButtons
			raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
			local raycastResult = workspace:Raycast(character.PrimaryPart.Position, Vector3.new(0, -6, 0), raycastParams)
			
			if raycastResult and raycastResult.Instance then
				if buttons[raycastResult.Instance] then
					buttons[raycastResult.Instance].active = true
				end
			end
		end
	end
	
	task.wait()
	
	for instance, button in pairs(buttons) do
		if button.active then
			instance.Material = Enum.Material.Neon
		else
			instance.Material = Enum.Material.Plastic
		end
	end
end
