Hello, I have a script test, that uses data persistence, so when a user clicks it then rejoins, it clones it and makes it 2 points above the original block. So what I need help with is for someone to change that so it will save there inventory, so if they pick up a weapon and click it then rejoin they will still have the weapon. Here is the code. Ill add comments where you have to change it . Thanks.
local Brick = script.Parent
local Key = "Part"
local Message = Instance.new("Message")
game.Players.PlayerAdded:connect(function(Player)
Player:WaitForDataReady()
local Object = Player:LoadInstance(Key)
if (Object ~= nil) then
Object.Parent = game.Workspace
Object.Anchored = true
Object.CFrame = CFrame.new(Brick.Positin+Vector3.new(0,2,0)) --this line above makes it another brick and saves.
Message.Text = "Success"
Message.Parent = game.Workspace
wait(5)
Message:Remove()
end
end)
game.Players.PlayerRemoving:connect(function(Player)
Player:SaveInstance(Key, Brick)
Thanks!
end) |