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

.Changed:Connect, but only on change not reconnect!?

Asked by 5 years ago

This works perfectly for rewarding the player when "Stage" is a multiple of 5, but the issue I've run into is that if a player is on stage 5 and continually reloads they'll keep being rewarded. is there a way i can make this function only applicable when changing, and not during initial "creation", or being pulled from the DataStore.

    game.Players.PlayerAdded:Connect(function(plr)
        local Leaderstats = plr:WaitForChild("leaderstats")
        local Stage = Leaderstats:WaitForChild("Stage")
        local Gems = plr:WaitForChild("Gems")
        local Skips = plr:WaitForChild("Skips")

        Stage.Changed:Connect(function(new)
            if new % 5 == 0 then
                Gems.Value = Gems.Value + 10
            end
        end)

    end)
0
Could you explain it a little better? yHasteeD 1819 — 5y
0
Instead of having a separate script do it all from one script. If that's your only script then a separate script is creating the leaderstats. User#19524 175 — 5y
0
Okay let me merge together my Datastore script and this script, ill see if that works. DinozCreates 1070 — 5y
0
You're scary good at this inca. Problem is now resolved, but how was having them in different locations causing the issue? DinozCreates 1070 — 5y
0
Also please send an answer so i can mark it :) Thanks!!! DinozCreates 1070 — 5y

Answer this question