generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Data Persistence Script Needs Help.

Previous Thread :: Next Thread 
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
03 Nov 2011 06:34 PM
#I have this script set-up to print output as a message to the player.PlayerGui so that the player (Me) can see the OutPut during gameplay. the output tells me that "PositionInstance" equals nil, when I know it shouldn't. Can any of you help?

wait(2)
player = script.Player.Value
SaveGui = script.Gui.Value.Save
LoadGui = script.Gui.Value.Load

function Save()
if player.DataReady == false then
    SaveGui.TextColor3 = Color3.new(1, 0, 0)
    wait(1)
    SaveGui.TextColor3 = Color3.new(1, 1, 1)
    return
end
positionsave = script.Gui.Value.CurrentPos.PositionOfPlayer
    succ, ret = pcall(function() player:SaveInstance("TorsoPosition", positionsave.Value)
        if succ then
            message = Instance.new("Message", player.PlayerGui)
            message.Text = string.format("Saved Position: %s, %s, %s", math.floor(positionsave.Value.X), math.floor(positionsave.Value.Y), math.floor(positionsave.Value.Z))
            print("Successfully saved")
            wait(4)
            message.Parent = nil
            message = nil
        else print("Error Saving: '"..tostring(ret).."'.")
            message = Instance.new("Message", player.PlayerGui)
            message.Text = "An Error Ocured: '"..tostring(ret).."'."
            wait(4)
            message.Parent = nil
            message = nil
        end
    end)
end

function Load()
positionload = script.Gui.Value.CurrentPos.PositionOfPlayer
if player.DataReady == false then
    LoadGui.TextColor3 = Color3.new(1, 0, 0)
    wait(1)
    LoadGui.TextColor3 = Color3.new(1, 1, 1)
    return
end
    succ2, ret2 = pcall(function() PositionInstance = player:LoadInstance("TorsoPosition")
        if succ2 then
            if PositionInstance then
                print("Successfully Loaded")
                player.Character.Torso.CFrame = PositionInstance.Value
                positionload.Value = PositionInstance.Value
            else pcall(function() message = Instance.new("Message", player.PlayerGui)
                    message.Text = "An Error Ocured(Load2): '"..tostring(ret2).."'."
                    wait(4)
                    message.Parent = nil
                    message = nil
                end)
            end
        else pcall(function() message = Instance.new("Message", player.PlayerGui)
                message.Text = "An Error Ocured(Load1): '"..tostring(ret2).."'."
                wait(4)
                message.Parent = nil
                message = nil
            end)
        end
    end)
end

SaveGui.MouseButton1Up:connect(Save)
LoadGui.MouseButton1Up:connect(Load)

print("Script 'game."..script:GetFullName().."' has succsessfully loaded up with no starting errors.")
Report Abuse
YouLeaveUsNothing is not online. YouLeaveUsNothing
Joined: 22 Oct 2011
Total Posts: 160
03 Nov 2011 06:44 PM
BLOODY HELL THAT'S SOME NICE ALT +255-ING

­-I will change Roblox forever. You will see soon.
Report Abuse
br45entei is not online. br45entei
Joined: 06 Nov 2010
Total Posts: 1058
03 Nov 2011 06:47 PM
...Thanks, I guess. I figured out that I was saving the .Value of the position instance, instead of the instance itself, so I'm off to test it again.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image