RenderStepped stops working for no reason?

I’m currently trying to make it so a billboardGui gets enabled when the player is close to a mesh, but after the billboard gets enabled the renderstepped just stops running. Heres my script [ONLY RELEVANT PART IS AT THE BOTTOM]:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Drops = ReplicatedStorage:WaitForChild("ChestsVisuals")
local Chests = workspace:WaitForChild("Chests")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

task.wait(3)

for i, v in pairs(Chests:GetChildren()) do
	local chestDrops = Drops:FindFirstChild(v.Name)
	
	if chestDrops then
		chestDrops = chestDrops.Drops
	end
	
	if chestDrops ~= nil then
		
		local billboardTemp = script.Template:Clone()
		local container = billboardTemp:WaitForChild("Container")
		local MainFrame = container:WaitForChild("MainFrame")
		local template = MainFrame:WaitForChild("Template")
		local button = billboardTemp:WaitForChild("OpenButton")
		
		billboardTemp.Name = v.Name
		billboardTemp.Adornee = v.RarityAdornee
		billboardTemp.Enabled = true
		billboardTemp.Parent = script.Parent.Parent.EggBillboards
		
		local drops = {}
		
		for x, drop in pairs(chestDrops:GetChildren()) do
			table.insert(drops,drop.Value)
		end
		
		table.sort(drops)
		
		for i = 1, math.floor(#drops/2) do
			local j = #drops - i + 1
			drops[i], drops[j] = drops[j], drops[i]
		end
		
		for _, rarity in pairs(drops) do
			for _, drop in pairs(chestDrops:GetChildren()) do
				if drop.Value == rarity then
					local clonedTemp = template:Clone()

					clonedTemp.Name = drop.Name
					clonedTemp.Rarity.Text = tostring(drop.Value) .. "%"
					clonedTemp.Visible = true
					clonedTemp.Parent = MainFrame
					break
				else
					continue
				end
			end
		end
		
		
		RunService.RenderStepped:Connect(function()
			print("working")
			if player:DistanceFromCharacter(v.ChestMesh.Position) < 30 then
				for _, billboard in pairs(script.Parent.Parent.EggBillboards:GetChildren()) do
					if billboard.Name ~= v.Name then
						billboard.Enabled = false
					else
						billboard.Enabled = true
					end
				end
			else
				billboardTemp.Enabled = false
			end
		end)
	end
end

Is the script this is running in somehow get deleted?

Create a “wait” condition, to see if it works.

nevermind im dumb i solved the issue

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