I made a script that would fire whenever a player's leaderboard points changes however its giving me this error:
00:42:37.830 - Workspace.Script:11: attempt to index number with 'Changed'
Does this mean that I can't use numbers with the changed event? This is my entire script if it helps:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Parent = leaderstats
Points.Value.Changed:Connect(function(Value)
if Value == 5 then
game.Workspace.door1.Transparency = 0.5
game.Workspace.door1.CanCollide = false
end
end)
end)

4 comments
It's ultimately best to hone in onto the property that changed—the signal activates upon any adjustment. You can do this with Points:GetPropertyChangedSignal("Value"):Connect(callback)
no, it doesnt really make a difference when you take in to account everything else
Feahren, it's actually better to use .Changed in this instance because we're dealing with Value objects, the .Changed event with only check for changes in the value which uses less resources than the GetPropertyChangedSignal listener.
Thanks for it Ziffixture. Never before heard about var:GetPropertyChangedSignal("Value"):Connect(callback)