Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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)
0
Wait, so it was not originally in a localscript? Then why did you use localplayer if it was not originally in a localscript? hiimgoodpack 2009 — 6y
0
He's just asking how to get it work with a LocalScript. He didn't actually try it from the server... Precisionly 103 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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!

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. TechnologicalDiamond 2 — 6y
0
TURN the while wait do into a function.* Soz :c TechnologicalDiamond 2 — 6y
0
What..?This is... nothing to to with my question... TinyScripter 70 — 6y
0
@TinyScripter This is supposed to make it so that if it detects that you have a changed coin value, it updates. TechnologicalDiamond 2 — 6y
Ad

Answer this question