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
 

TOOL DATA PERSISTANCE WITHOUT /SAVE /LOAD

Previous Thread :: Next Thread 
GodOfAllLimiteds is not online. GodOfAllLimiteds
Joined: 13 Nov 2011
Total Posts: 4667
07 Apr 2014 01:49 PM
Anyone have anything that will do the trick?

Silly n00bs, Robux are for BC'ers!
Report Abuse
GodOfAllLimiteds is not online. GodOfAllLimiteds
Joined: 13 Nov 2011
Total Posts: 4667
07 Apr 2014 01:51 PM
bump

Silly n00bs, Robux are for BC'ers!
Report Abuse
M39a9am3R is not online. M39a9am3R
Joined: 10 Nov 2012
Total Posts: 1933
07 Apr 2014 01:53 PM
So, do you want server to server or server only?
Report Abuse
GodOfAllLimiteds is not online. GodOfAllLimiteds
Joined: 13 Nov 2011
Total Posts: 4667
07 Apr 2014 01:54 PM
server

Silly n00bs, Robux are for BC'ers!
Report Abuse
GodOfAllLimiteds is not online. GodOfAllLimiteds
Joined: 13 Nov 2011
Total Posts: 4667
07 Apr 2014 01:55 PM
server to server*

Silly n00bs, Robux are for BC'ers!
Report Abuse
M39a9am3R is not online. M39a9am3R
Joined: 10 Nov 2012
Total Posts: 1933
07 Apr 2014 02:02 PM
If it's server to server, then you need load and save instance...
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
07 Apr 2014 02:17 PM
These are not mine! I think you have to save. Unless you can make it autosave every 10 seconds?

Try this:
Data:
function onPlayerEntered(player)
wait()
player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
wait()
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end

function onPlayerLeaving(player)
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end

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





Tool:
forceSaveCommand = "save"
forceLoadCommand = "load"

clearStarterGearOnLoad = true
dataReadyWaitTimeout = 8

saveSuccessMessage = "Your tools have been saved"

loadSuccessMessage = "Your tools have been loaded"

loadErrorMessage = "Your tools could not be loaded. Chat \"" .. forceLoadCommand .. "\" to retry."

saveErrorMessage = "Your tools could not be saved. Chat \"" .. forceSaveCommand .. "\" to retry."


loadFastMessage = "You can only load your tools every 3 minutes."

saveFastMessage = "You can only save your tools every 30 seconds."

dpPrefix = "SavedTools-0-"

debug = false

save_times = {}
load_times = {}

debris = game:GetService("Debris")

function tellPlayer(player, text, time)
if not player.Parent then return end
local m = Instance.new("Message", player:findFirstChild("PlayerGui"))
m.Text = text
debris:AddItem(m, time or 3)
end

function waitForDataReady(player)
local start = tick()
while tick() < start + dataReadyWaitTimeout do
if player.DataReady then return true end
wait()
end
return false
end

function playerSave(player)
if not waitForDataReady(player) then tellPlayer(player, saveErrorMessage) return end

if (save_times[player] or 0) + 30 > tick() then tellPlayer(player, saveFastMessage) return end
save_times[player] = tick()

local gear = player:findFirstChild("StarterGear")
if not gear then tellPlayer(player, saveErrorMessage) return end
local tools = gear:GetChildren()
local worked = false
pcall(function ()
player:SaveNumber(dpPrefix .. "Count", #tools)
worked = true
end)
if not worked then tellPlayer(player, saveErrorMessage) return end
for i, tool in pairs(tools) do
pcall(function ()
player:SaveInstance(dpPrefix .. tostring(i), tool)
end)
end
tellPlayer(player, saveSuccessMessage)
end

function playerLoad(player)
if not waitForDataReady(player) then
tellPlayer(player, loadErrorMessage)
return
end

if (load_times[player] or 0) + 60*3 > tick() then tellPlayer(player, loadFastMessage) return end
load_times[player] = tick()

local gear = player:findFirstChild("StarterGear")
local backpack = player:findFirstChild("Backpack")
local current = gear:GetChildren()
local count = 0
pcall(function ()
count = player:LoadNumber(dpPrefix .. "Count")
end)
local tools = {}
for i = 1, count do
pcall(function ()
tools[#tools + 1] = player:LoadInstance(dpPrefix .. tostring(i))
end)
end
for i, tool in pairs(tools) do
local copy = tool:clone()
copy.Parent = backpack
local copy2 = tool:clone()
copy2.Parent = gear
end
if clearStarterGearOnLoad then
for i, tool in pairs(current) do
tool:remove()
end
end
tellPlayer(player, loadSuccessMessage)
end

function onPlayerChatted(player, message, recipient)
message = message:lower()
if message == forceSaveCommand then
playerSave(player)
elseif message == forceLoadCommand then
local s, e = pcall(function ()
playerLoad(player)
end)
if not s then
if debug then tellPlayer(player, "playerLoad error:" .. e) end
end
end
end

function onPlayerEntered(player)
player.Chatted:connect(function (msg, rec) onPlayerChatted(player, msg, rec) end)
playerLoad(player)
end

function onPlayerLeft(player)
local s, e = pcall(function ()
playerSave(player)
end)
if not s then
if debug then Instance.new("Message", workspace).Text = "playerSave error:" .. e end
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeft)
Report Abuse
GodOfAllLimiteds is not online. GodOfAllLimiteds
Joined: 13 Nov 2011
Total Posts: 4667
08 Apr 2014 01:28 PM
any other scripts. That one didnt save.

Silly n00bs, Robux are for BC'ers!
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
08 Apr 2014 01:53 PM
Why don't you try autosaving? Found this script from 2009:


function saveWeapons(player)
local bin = player.StarterGear
local stuff = player.Backpack:GetChildren()
for i = 1,#stuff do
local name = stuff[i].Name
if game.StarterPack:findFirstChild(name)==nil and player.StarterGear:findFirstChild(name)==nil then
stuff[i]:Clone().Parent = bin
end
end
local char = player.Character:GetChildren()
for i = 1,#char do
if char[i].className == "Tool" then
local name = char[i].Name
if game.StarterPack:findFirstChild(name)==nil and player.StarterGear:findFirstChild(name)==nil then
char[i]:Clone().Parent = bin
end
end
end
end

function onRespawned(player)
local findBin = game.Lighting:findFirstChild(player.Name)
if findBin~=nil then
local stuff = findBin:GetChildren()
for i = 1,#stuff do
stuff[i]:Clone().Parent = player.Backpack
end
findBin:Remove()
end
player.Character.Humanoid.Died:connect(function()
saveWeapons(player)
end)
end

function onPlayerEntered(newPlayer)
newPlayer.Changed:connect(function (property)
if (property == "Character") then
onRespawned(newPlayer)
end
end)
while true do
if newPlayer.Character~=nil then break end
wait()
end
newPlayer.Character.Humanoid.Died:connect(function()
saveWeapons(newPlayer)
end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
08 Apr 2014 01:54 PM
Above wasn't tested, not sure what it's for. So yeah... Looks like what you need.
Report Abuse
GodOfAllLimiteds is not online. GodOfAllLimiteds
Joined: 13 Nov 2011
Total Posts: 4667
08 Apr 2014 02:04 PM
That didnt work either. Yea i meant to make it autosave.

Silly n00bs, Robux are for BC'ers!
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
08 Apr 2014 02:10 PM
There has to be some sort of way, try PMing DataStore, he's great with these things.
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