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

Save and load bricks to base not working. Why?

Asked by 6 years ago

Hi, my name is Pavel and i'am from Russia, so do not ask why my english is bad.

There is problem. I creating a game with garage, this garage need to have Save/Load function for saving bricks.

Cause i'am bad in scripts, i got and idea to do something like this:

function onClick(click)
game.Lighting.CheckID.Value = 0
for i=300, 1, -1 do
if click.leaderstats[game.Lighting.CheckID.Value].Value == Vector3.new(0, 0, 0) then
game.Lighting.CheckID.Value = game.Lighting.CheckID.Value + 1
else
game.Lighting.EeeeeGiftOfBoi1:Clone().Parent = game.Workspace[click.PlotSave.Value]
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi1.Handle.Position = click.leaderstats[game.Lighting.CheckID.Value].Value
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi1.Name = "EeeeeGiftOfBoi2"
game.Lighting.CheckID.Value = game.Lighting.CheckID.Value + 1
end
end
for i=300, 1, -1 do
if click.leaderstats[game.Lighting.CheckID.Value].Value == Vector3.new(0, 0, 0) then
game.Lighting.CheckID.Value = game.Lighting.CheckOID.Value + 1
else 
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi2.Handle.Orientation = click.leaderstats[game.Lighting.CheckID.Value].Value
game.Lighting.CheckID.Value = game.Lighting.CheckID.Value + 1
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi2.Name = "EeeeeGiftOfBoi"
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

This is Load script for garage.

First part of script working good, but the second part what needed to give Orientation to brick won't works :c

Save script working, that's it:

function onClick(click)
game.Lighting.ItemID.Value = 0
for i=300, 1, -1 do
if click.leaderstats[game.Lighting.ItemID.Value].Value == Vector3.new(0, 0, 0) and game.Workspace[click.PlotSave.Value]:FindFirstChild('EeeeeGiftOfBoi') then
click.leaderstats[game.Lighting.ItemID.Value].Value = game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi.Handle.Cords.Value
game.Lighting.ItemID.Value = game.Lighting.ItemID.Value + 1
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi.Name = "EeeeeGiftOfBoi1"
else if game.Workspace[click.PlotSave.Value]:FindFirstChild('EeeeeGiftOfBoi') then
click.leaderstats[game.Lighting.ItemID.Value].Value = game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi.Handle.Cords.Value
game.Lighting.ItemID.Value = game.Lighting.ItemID.Value + 1
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi.Name = "EeeeeGiftOfBoi1"
else
game.Lighting.ItemID.Value = game.Lighting.ItemID.Value + 1
end
end
end
for i=300, 1, -1 do
if click.leaderstats[game.Lighting.ItemID.Value].Value == Vector3.new(0, 0, 0) and game.Workspace[click.PlotSave.Value]:FindFirstChild('EeeeeGiftOfBoi1') then
click.leaderstats[game.Lighting.ItemID.Value].Value = Vector3.new(game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi1.Handle.Orientation)
game.Lighting.ItemID.Value = game.Lighting.ItemID.Value + 1
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi1:Destroy()
else if game.Workspace[click.PlotSave.Value]:FindFirstChild('EeeeeGiftOfBoi1') then
click.leaderstats[game.Lighting.ItemID.Value].Value = Vector3.new(game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi1.Handle.Orientation)
game.Lighting.ItemID.Value = game.Lighting.ItemID.Value + 1
game.Workspace[click.PlotSave.Value].EeeeeGiftOfBoi1:Destroy()
else
game.Lighting.ItemID.Value = game.Lighting.ItemID.Value + 1
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

Alright, i wanna ask you all what's wrong in those scripts. If there are BETTER method to save/load system, give me an example pls, i'am bad in scripts.

Thanks from future.

Answer this question