#My script is not working altho has no errors in output.
287 messages · Page 1 of 1 (latest)
** You are now Level 4! **
no errors in output.
Where does it not print?
** You are now Level 3! **
Oh okay.
Try add a print add the beginning of the .Removing event just to make sure that works
otherwise it's probably because your "Folder:FindFirstChild(name)" isn't true
if Folder:FindFirstChild(name) then
playerremoving?
yeah try that
i put it in the first line
Mhm
can you send screenshot of the script?
You sure there's no errors? this line seems weird: for i, name in inventory do
well bassically inventory is a variable that gets data, a table data
yeah well you would use in pairs(inventory)
it printed
screenshot code
i did but it failed
Okay so first of there's a visible error
lowercase the "I" on whatever line that is
oh ill change that
** You are now Level 5! **
because the "item" property isn't with a uppercase I
yeah
If you got one of those red marks it means your script has a clear error that needs to be fixed
okay it didn't print the first line?
idk its supposed to get all BP children names and add them to the table
but when i leave it does not save anything
Or when i join it does not do anything
Okay, but it does detect you've left?
plr.Backpack
yes
Okay.
i use a tool
Change the pairs to "ipairs"
yes
try print BP:GetChildren() and show me
huh
i don't think u can print objects
do u know how to make saving inventory scripts?
try this
game:GetService("Players").PlayerRemoving:Connect(function(Player)
print("Player:", Player, "has discoonected.")
print(Player.Backpack:GetChildren())
local char = Player.Character or Player.CharacterAdded:Wait()
local Items = {}
for _, Object in ipairs(Player.Backpack:GetChildren()) do
print(Object)
if Object then
print("Object is a tool!")
table.insert(Items,Object.Name)
print("saved",Object,"for",Player)
end
end
MainData:SetAsync(Player.UserId,Items)
end)
yes.
replace the removingevent
TEACH ME
wait I had 1 error in the script wait
can you show it all?
expand the table as well
k
game:GetService("Players").PlayerRemoving:Connect(function(Player)
print("Player:", Player, "has discoonected.")
print(Player.Backpack:GetChildren())
local char = Player.Character or Player.CharacterAdded:Wait()
local Items = {}
for _, Object in ipairs(Player.Backpack:GetChildren()) do
print(Object)
if Object:IsA("Tool") then
print("Object is a tool!")
table.insert(Items,Object.Name)
print("saved",Object,"for",Player)
end
end
print(#Items)
MainData:SetAsync(Player.UserId,Items)
end)
replace with that
screenshot the whole output
yes
by picking it up
its a normal pickable tool
oh ok.
No shouldn't be needed
** You are now Level 4! **
oh
If you check in the explorer while in-game
wait
1 thing
When you discoonect from the game
Is the tool equipped in your hand?
nope
i sometimes equip it and leave
Ok, try unequip and then leave
k]
then look at the output
same
Nothing?
yep same
Ok, try check inside the property table if the item is there
k
ok
from client view its in the backpack and the same for server view
And there's a tool inside there?
yes
try print the players backpack randomly while in-game
objects can't be printed tho
how?
Print(backpack)?
k
bc you don't do Backpack:GetChildren()
i did
would print a table, also why is it local?
wdym
it's printed from the client
a local script
printing something with :GetChildren() should always print a table idk what have happened
sorry i caused u alot of trouble
u sure its my entire same script?
send urs if u don't mind
Try go to the server, add a tool property and then leave
I'm using your script, the part I sent to you
it works
try:
game:GetService("Players").PlayerRemoving:Connect(function(Player)
print("Player:", Player, "has discoonected.")
print(Player.Backpack:GetChildren())
local Items = {}
for _, Object in ipairs(Player.Backpack:GetChildren()) do
print(Object)
if Object:IsA("Tool") then
print("Object is a tool!")
table.insert(Items,Object.Name)
print("saved",Object,"for",Player)
end
end
print(#Items)
MainData:SetAsync(Player.UserId,Items)
end)
see prints, with tool
do i try chat gpt troubleshoot ?
no
k
try what I sent u
** You are now Level 6! **
OBJECT IS A TOOL
AND 1
u sure? I can do it if u want
just send the script
I removed a line
you had a line waiting for the character
however as the character already has been removed it was waiting in forever
idk why it was there, didn't notice it at first lol
Yeah, you had smth like:
local Character = plr.character or Character.CharacterAdded:Wait()
** You are now Level 5! **
yea it was like that
and it would wait forever
haha seriously?
bro ur a lifesaver
wow
I didn't even notice that line at first tbh
Well
If you would like to I'll fix the other part too
thx
i never thought it was the problem i thought it was a fix
since it printed nil for char
everytime
but wait i removed the char part
why did i keep the variable
💀

idk why would would ever want to use the character in that script tbh
1 reason could be to unequip all tools tho
I saw a yt tutorial
that used the same as this
as tools that are equipped are inside the character, and not saved
but used char and backpack
Yeah, if the player has a tool equipped it won't be saved with this script
as the tool is inside the character, not the backpack when it's equipped
so what do i do?
i gotta use char
but
its nil when its in
bc plr loads faster than char
so it identifies as nil
char
some guy suggested me to use repeat wait() until char
game:GetService("Players").PlayerRemoving:Connect(function(Player)
print("Player:", Player, "has discoonected.")
print(Player.Backpack:GetChildren())
local Items = {}
for _, Object in ipairs(Player.Backpack:GetChildren()) do
print(Object)
if Object:IsA("Tool") then
print("Object is a tool!")
table.insert(Items,Object.Name)
print("saved",Object,"for",Player)
end
end
print(#Items)
MainData:SetAsync(Player.UserId,Items)
end)
You'll just do CharacterRemoving first then the PlayerRemoving I'd say
so i use char as charremoving?
variable
let me cook hold on
smells good
u there
k np sry
alr
I think dinner is ready
try this
game:GetService("Players").PlayerAdded:Connect(function(Player)
local Items = {}
Player.CharacterRemoving:Connect(function(Character)
local CharacterChildren = Character:GetChildren()
for _, Obj in ipairs(CharacterChildren) do
if Obj:IsA("Tool") then
table.insert(Items, Obj.Name)
end
end
end)
Player.CharacterAdded:Connect(function(char)
table.clear(Items)
end)
game:GetService("Players").PlayerRemoving:Connect(function(Player)
print("Player:", Player, "has discoonected.")
print(Player.Backpack:GetChildren())
for _, Object in ipairs(Player.Backpack:GetChildren()) do
print(Object)
if Object:IsA("Tool") then
print("Object is a tool!")
table.insert(Items,Object.Name)
print("saved",Object,"for",Player)
end
end
print(#Items)
MainData:SetAsync(Player.UserId,Items)
end)
end)
just switch out the playerremoving part to this
and try to equip 1 tool and see if it saves
k tysm
it worked?
has alot of errors
go eat ill try to do it myself u already done enough
k
weird
ik
Mk, send me the errors
you've copied the code wrong
should i keep it on Playeradded?
game:GetService("Players").PlayerAdded:Connect(function(Player)
local Items = {}
Player.CharacterRemoving:Connect(function(Character)
local CharacterChildren = Character:GetChildren()
for _, Obj in ipairs(CharacterChildren) do
if Obj:IsA("Tool") then
table.insert(Items, Obj.Name)
end
end
end)
Player.CharacterAdded:Connect(function(char)
table.clear(Items)
end)
game:GetService("Players").PlayerRemoving:Connect(function(Player)
print("Player:", Player, "has discoonected.")
print(Player.Backpack:GetChildren())
for _, Object in ipairs(Player.Backpack:GetChildren()) do
print(Object)
if Object:IsA("Tool") then
print("Object is a tool!")
table.insert(Items,Object.Name)
print("saved",Object,"for",Player)
end
end
print(#Items)
MainData:SetAsync(Player.UserId,Items)
end)
end)
wait
?
use ```lua
oh
`
game:GetService("Players").PlayerAdded:Connect(function(Player)
local Items = {}
Player.CharacterRemoving:Connect(function(Character)
local CharacterChildren = Character:GetChildren()
for , Obj in ipairs(CharacterChildren) do
if Obj:IsA("Tool") then
table.insert(Items, Obj.Name)
end
end
end)
Player.CharacterAdded:Connect(function(char)
table.clear(Items)
end)
game:GetService("Players").PlayerRemoving:Connect(function(Player)
print("Player:", Player, "has discoonected.")
print(Player.Backpack:GetChildren())
for , Object in ipairs(Player.Backpack:GetChildren()) do
print(Object)
if Object:IsA("Tool") then
print("Object is a tool!")
table.insert(Items,Object.Name)
print("saved",Object,"for",Player)
end
end
print(#Items)
MainData:SetAsync(Player.UserId,Items)
end)
end)
there
copy that
and replace
worked
again tysm
i wish u good luck
👍
bye 🙂