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

Why is this simple Values script not working? [SOLVED]

Asked by 9 years ago

I literally don't understand why this isn't working. I've edited it so much and it just doesn't work. I get no output, the values just simply don't insert itself into the player.

wait(2) -- wait for the character to load

pointsKey = "PlayerPoints"
coinsKey = "PlayerCoins"
newKey = "PlayerNew"

function assignValues(plr)
    plr:WaitForDataReady();
    wait(2)
    points = Instance.new("NumberValue")
    coins = Instance.new("NumberValue")
    notnew = Instance.new("BoolValue")


    --new
    notnew.Parent = plr
    notnew.Name = "NotNew"
    notnew.Value = plr:LoadBoolean(newKey)

    --points and coins
    points.Parent = plr
    points.Name = "Points"

    coins.Parent = plr
    coins.Name = "Coins"

    if notnew.Value == false then --check if player is new
        plr.NotNew.Value = true
        plr.Points.Value = 0
        plr.Coins.Value = 0
            if plr.PlayerGui.ScreenGui.Tutorial.Visible == false then
                plr.PlayerGui.ScreenGui.Tutorial.Visible = true
                plr.PlayerGui.ScreenGui.Tutorial.Position = UDim2.new(0, -600, 0, 100)
                plr.PlayerGui.ScreenGui.Tutorial:TweenPosition(UDim2.new(0,500,0,100), "Out", "Bounce", 1)
            end
    elseif notnew.Value == true then
        plr.Points.Value = plr:LoadNumber(pointsKey)
        plr.Coins.Value = plr:LoadNumber(coinsKey)
    end

    points.Changed:connect(function() saveStats(plr) end)
    coins.Changed:connect(function() saveStats(plr) end)
    notnew.Changed:connect(function() saveStats(plr) end)

end

function saveStats(plr)
    --coins and points save
    plr:SaveNumber(coinsKey, plr.Coins.Value)
    plr:SaveNumber(pointsKey, plr.Points.Value)
    --new save
    plr:SaveBoolean(newKey, plr.NotNew.Value)
end

game.Players.PlayerAdded:connect(assignValues)







0
You are testing on a ROBLOX server, right? Have you verified that `WaitForDataReady` ever finishes? (e.g., `print("Ready")` afterwards and then consult F9?). Separately may I recommend "previouslyPlayed" or something instead of "notNew" so that you don't get the falses/nots confused in your head? Finally, you should not have the `wait(2)` at the beginning. BlueTaslem 18071 — 9y
0
I am testing on a ROBLOX Server, yes. I've tried starting a Server from Studio, and simply playing from my game menu. I added a print, and it did indeed print. I'm not sure what the problem is. I also removed the wait. SlickPwner 534 — 9y

1 answer

Log in to vote
0
Answered by
Adryin 120
9 years ago

You haven't assigned what plr is for the functions, try doing this for the AssignValue function.

game.Players.PlayerAdded:connect(function(plr)


-- what you want here.

end)
0
I edited it, and it didn't make a difference. Same problem. SlickPwner 534 — 9y
Ad

Answer this question