I am using the script below to detect if a player reaches 50 value for a leaderstat called “Prizes Won,” and triggers a RemoteEvent. However, the script fails to trigger the RemoteEvent once the player reaches 50 prizes (A player goes from 49 to 50 prizes, but the RemoteEvent doesn’t ever trigger). What might be causing the issue?
local event = game.ReplicatedStorage:WaitForChild("RemoveProDoor")
local door = game.Workspace:WaitForChild("ProDoor")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = plr:WaitForChild("leaderstats")
local prizes: IntValue = leaderstats:WaitForChild("Prizes Won")
if prizes.Value >= 50 then
event:FireClient(plr, door)
end
prizes.Changed("Value"):Connect(function()
if prizes.Value >= 50 then
event:FireClient(plr, door)
end
end)
end)
Thanks!