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

How do I fix argument isn't valid in this save position script?

Asked by 5 years ago
function onPlayerEntered(player)
        player:WaitForDataReady()
        posx = player:LoadNumber(posx)
        wait(15)
        if posx ~= nil then
            local ScoreLoaded = player:LoadNumber(posx)
            local ScoreLoadedb = player:LoadNumber(posy)
            local ScoreLoadedc = player:LoadNumber(posz)
            local team = player:LoadString("team")
            player.TeamColor = team
            player.Character.Torso.Position = Vector3.new(ScoreLoaded, ScoreLoadedb, ScoreLoadedc)
        else
        end
        repeat
            posa =  player.Character.Torso.Position.x
            posb = player.Character.Torso.Position.y
            posc = player.Character.Torso.Position.z
            team = player.TeamColor
            print'Position Saved'
            wait(10)
        until nil
    end

    function onPlayerLeaving(player)
        player:SaveNumber(posx, posa)
        player:SaveNumber(posy, posb)
        player:SaveNumber(posz, posc)
        player:SaveString("team", team)
    end

    game.Players.PlayerAdded:connect(onPlayerEntered)
    game.Players.PlayerRemoving:connect(onPlayerLeaving)

basically i want to save the players position every like 10 seconds or so, and only load it when the player rejoins the game

however it says Argument isnt valid or something?

Answer this question