So I made a leaderstats and a value in it. I want to make a script that checks whenever the value is changed and if u possess certain requirements then it will do the following actions. but my script does not do anything when the value changes
local db = true
game.Players.PlayerAdded:Connect(function(plr)
wait(5)
local Leader = plr:WaitForChild("leaderstats")
local ExpStat = Leader:WaitForChild("Exp")
local Exp = ExpStat.Value
ExpStat.Changed:Connect(function(Change)
local ExpGain = Change - Exp
if ExpGain > 0 then
if db then db = false
Exp = Exp - ExpGain
wait(0.1)
Exp = Exp + (ExpGain * 2)
wait(0.1)
db = true
end
end
end)
end)
Can you tell me whats wrong because i have no idea

1 comment
There is a requirement there i just removed it temporary for testing