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

my tool saving script is not working. why?

Asked by 9 years ago

Im trying to make a script that can save the tools that players gained during their journey i made this so far but is not working


local key = "keyg3n"

local players = game:GetService("Players")

game.Players.PlayerAdded:connect(function(loady)

local player = players:GetPlayerFromCharacter(loady)

local backpack = player.BackPack

loady:WaitForDataReady()

tools = loady:loadInstance(key..player.Name)

tools.Parent = backpack

end)

game.Players.PlayerRemoving:connect(function(savy)

local player = players:GetPlayerFromCharacter(savy)

local backpack = player.BackPack

local inventory = backpack:GetChildren()

savy:WaitForDataReady()

if inventory then

    savy:saveInstance(key..player.Name)

end

end)


what is wrong on my script?

it is supposed to keep the tools that players gained whem they leave or die

NOTE: its my first time asking a question so im sorry for any mistake above

1 answer

Log in to vote
-1
Answered by 9 years ago

Maybe the mistake is that you wrote 'BackPack' instead of 'Backpack'. Also, for these lines

game.Players.PlayerAdded:connect(function(loady)
game.Players.PlayerLeaving:connect(function(savy)

You would replace game.Players with players.

0
there are no lines saying played added etc NinjoOnline 1146 — 9y
0
ive replaced BackPack with Backpack but still nothing megacosmos5000 0 — 9y
Ad

Answer this question