Script Not Detecting Leaderstat Change

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! :slight_smile:

The script gives the following error:

ServerScriptService.50PrizesWon:14: attempt to call a RBXScriptSignal value

prizes.Changed("Value"):Connect(function()
		if prizes.Value >= 50 then
			event:FireClient(plr, door)
		end
	end)

you’re attempting to call Changed, and it errors because it’s not a function. do this instead:

prizes.Changed:Connect(function()
		if prizes.Value >= 50 then
			event:FireClient(plr, door)
		end
	end)

Got it, I’ll make the change, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.