I wrote this function in a framework and it runs on the client when the player runs but doesnt work
CheckStuds.CheckStuds = function(player: Player)
local leaderstats = player:WaitForChild("leaderstats")
local Studs = leaderstats:WaitForChild("Studs")
local StudsFolder = game.Workspace:WaitForChild("Studs")
for _, studModel in ipairs(StudsFolder:GetChildren()) do
if studModel:IsA("Model") then
local highlight = studModel:FindFirstChild("EffectHighlight"):IsA("Highlight")
local studValue = studModel:FindFirstChild("Stud"):IsA("NumberValue")
local touchPart = studModel:FindFirstChild("TouchPart"):IsA("Part")
if highlight and studValue and touchPart then
if Studs.Value >= studValue.Value then
highlight.Enabled = false
touchPart.CanTouch = false
end
end
end
end
end
return CheckStuds```
** You are now Level 1! **