how can I check whether the player’s attribute has changed? I did this using while wait, but as a result of this, many frames with one player are cloned.
local function prisons()
for i,plr in Players:GetPlayers() do
while wait (0.05) do
if plr:GetAttribute("WantedReason").Changed ~= "" then
local example = scrollingFrame.FrameButton
local framebutton = example:Clone()
framebutton.Parent = scrollingFrame
framebutton.Name = "Prison"
framebutton.NamePlr.Value = plr.Name
framebutton.PlrName.Text = plr.Name
framebutton.PlrWanted.Text = plr:GetAttribute("WantedReason")
print(framebutton.NamePlr.Value)
framebutton.Visible = true
task.wait(0.1)
end
end
end
end
prisons()
Players.PlayerAdded:Connect(function()
for index, value in pairs(script.Parent:GetChildren()) do
if value.Name == "Prison" then
value:Destroy()
end
end
prisons()
end)