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
 

[ Content Deleted ]

Previous Thread :: Next Thread 
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 03:07 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 03:10 AM
I was new to data persistance once, then I made an api so I could test stuff in offline mode, it can be found here: http://www.roblox.com/DataPersistanceTestAPI-item?id=61468831
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 03:19 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 03:32 AM
local Use_DB = true

function saveStat(plr,val,key)
if plr then
plr:WaitForDataReady()
plr:SaveNumber(key,val)
end
end

function loadStat(plr,key,stat)
if plr then
plr:WaitForDataReady()
stat.Value = plr:LoadNumber(key,val)
end
end

game.Players.PlayerAdded:connect(function(player)
Stat = Instance.new("IntValue",player)
Stat.Name = "leaderstats"
Altitude = Instance.new("IntValue",Stat)
Altitude.Name = "Altitude"
MaxAltitude = Instance.new("IntValue",Stat)
MaxAltitude.Name = "MaxAltitude"
while true do
local f = player.Character
Altitude.Value = f.Torso.Position.y-50
end
end --this should be causing an error, replace with )
if Use_DP then
loadStat(player,"MaxAltitude",MaxAltitude)
end
if Use_DP then --this will only be called when the player is added, try using MaxAltitued.Changed
if f.Torso.Position.y-50 ~= Altitude.Value then
if MaxAltitude.Value ~= Altitude.Value then
saveStat(player,Altitude.Value,"MaxAltitude")
end
end
end
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 03:40 AM
[ Content Deleted ]
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 03:45 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 03:46 AM
MaxAltitude.Changed:connect(function()
saveStat(player,MaxAltitude.Value,"MaxAltitude")
end)

or you could use the way I dislike, but should work

Max.Altitude.Changed:connect(function(value)
saveStat(player,value,"MaxAltitude")
end)
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 03:58 AM
[ Content Deleted ]
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 04:01 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 04:04 AM
local Use_DB = true

function saveStat(plr,val,key)
if plr then
plr:WaitForDataReady()
plr:SaveNumber(key,val)
end
end

function loadStat(plr,key,stat)
if plr then
plr:WaitForDataReady()
stat.Value = plr:LoadNumber(key,val)
end
end

game.Players.PlayerAdded:connect(function(player)
Stat = Instance.new("IntValue",player)
Stat.Name = "leaderstats"
Altitude = Instance.new("IntValue",Stat)
Altitude.Name = "Altitude"
MaxAltitude = Instance.new("IntValue",Stat)
MaxAltitude.Name = "MaxAltitude"
while true do
local f = player.Character
Altitude.Value = f.Torso.Position.y-50
end
end --nvm I missed the while my mistake
if Use_DP then
loadStat(player,"MaxAltitude",MaxAltitude)
end
if Use_DP then --this setion was changed
MaxAltitude.Changed:connect(function()
saveStat(player,MaxAltitude.Value,"MaxAltitude")
end)
end
) --this should probably be here to close the the PlayerAdded:connect(
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 04:06 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 04:14 AM

local Use_DB = true
function saveStat(plr,val,key)
if plr then
plr:WaitForDataReady()
plr:SaveNumber(key,val)
end
end

function loadStat(plr,key,stat)
if plr then
plr:WaitForDataReady()
stat.Value = plr:LoadNumber(key,val)
end
end

game.Players.PlayerAdded:connect(
function(player)
Stat = Instance.new("IntValue",player)
Stat.Name = "leaderstats"
Altitude = Instance.new("IntValue",Stat)
Altitude.Name = "Altitude"
MaxAltitude = Instance.new("IntValue",Stat)
MaxAltitude.Name = "MaxAltitude"
if Use_DP then --moved this above the while true do
loadStat(player,"MaxAltitude",MaxAltitude)
end
MaxAltitude.Changed:connect(
function()
if player.Torso.Position.y-50 ~= Altitude.Value then
if MaxAltitude.Value ~= Altitude.Value then
saveStat(player,Altitude.Value,"MaxAltitude")
end
end
end
)
while true do --should be in the player added thingy
local f = player.Character --not the best idea, but it works
Altitude.Value = f.Torso.Position.y-50
wait() --prevents crashes
end
end
)
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 04:26 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 04:34 AM
try this


local Use_DB = true
function saveStat(plr,val,key)
if plr then
plr:WaitForDataReady()
plr:SaveNumber(key,val)
end
end

function loadStat(plr,key,stat)
if plr then
plr:WaitForDataReady()
stat.Value = plr:LoadNumber(key,val)
end
end

game.Players.PlayerAdded:connect(
function(player)
local Stat = Instance.new("IntValue",player)
Stat.Name = "leaderstats"
local Altitude = Instance.new("IntValue",Stat)
Altitude.Name = "Altitude"
local MaxAltitude = Instance.new("IntValue",Stat)
MaxAltitude.Name = "MaxAltitude"
while true do
local f = player.Character
Altitude.Value = f.Torso.Position.y-50
wait()
if Use_DP then
loadStat(player,"MaxAltitude",MaxAltitude)
end
end --needed an end here
MaxAltitude.Changed:connect(
function()
if player.Torso.Position.y-50 ~= Altitude.Value then
if MaxAltitude.Value ~= Altitude.Value then
saveStat(player,Altitude.Value,"MaxAltitude")
end
end
end
)
end
) --the end was here
Report Abuse
myrco919 is not online. myrco919
Joined: 12 Jun 2009
Total Posts: 13241
25 Sep 2011 04:40 AM
[ Content Deleted ]
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 04:44 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 04:49 AM
Workspae.Script:26:Attempt to
something about f being undefined
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 04:55 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 04:57 AM
if it doesn't work i could check the problem with my api
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 05:00 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 05:01 AM
just post the script
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 05:11 AM
[ Content Deleted ]
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 05:12 AM
[ Content Deleted ]
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
25 Sep 2011 05:20 AM
[ Content Deleted ]
Report Abuse
natedogith1 is not online. natedogith1
Joined: 09 Aug 2008
Total Posts: 578
25 Sep 2011 05:22 AM
try testing this in studio with
local Use_DP=false
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