Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with making this LocalScript run when a stats is changed?

Hello! I have another question. How would I get this Notification to run in a LocalScript? I would really appreciate the help. Here is the LocalScript:

game.Players.LocalPlayer.Stats.Coins.Changed:connect(function(oldValue)
	local Number = game.Players.LocalPlayer.Stats.Coins.Value - oldValue
	game.StarterGui:SetCore("SendNotification", {
	Title = "Doge Coins";
	Text = "+"..Number.." Doge Coins";
	Icon = "";
	Duration = 5;
})
end)

2 comments

0

Wait, so it was not originally in a localscript? Then why did you use localplayer if it was not originally in a localscript?

0

He's just asking how to get it work with a LocalScript. He didn't actually try it from the server...

1 answer

This should work.

local coinstats = game.Players.LocalPlayer.Stats.Coins
local onevar = coinstats.Value
local twovar = 0
while wait() do
	twovar = coinstats.Value
	if not twovar == onevar then
		if twovar >= onevar then
			-- put script code here
		else
			-- put script code for losing dogecoins here
		end
	else
	onevar = twovar
	end
end

If not, please ask me. Thanks!

4 comments

0

BTW if you want to make it check every second, make the while wait() do a function, then call the function every second in another while wait(how long you want to wait) do.

0

TURN the while wait do into a function.* Soz :c

0

What..?This is... nothing to to with my question...

0

@TinyScripter This is supposed to make it so that if it detects that you have a changed coin value, it updates.

This discussion is preserved as it was. New answers, comments, and votes are closed.