im trying to save a player’s equipped tool but i can’t even detect if a player has an equipped tool when they leave in the first place
local Tool = Player.Character:FindFirstChildOfClass("Tool")
if Tool then
print("Tool found inside character.")
it doesnt print anything, but it does error “attempt to index nil with ‘FindFirstChildOfClass’”
When the player equips the tool, store it in a table on the server and save that when the player leaves. The tool gets deleted with the player before you can save it.
The way I check whether or not player is holding a tool on the server is like this:
local function checkTools(player)
for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
You could set up a datastore function to store the output of this function when a player leaves the server.
Maybe the issue is that by the time the player exit event fires, the character has already been destroyed. Perhaps you could try this:
- Player’s character fires the removing event:
- Add this to a table / dictionary , The key is the player, the value is a table consisting of the tool and a character added connection
- if the character added connection fires and the character respawns, clear the player’s index on the table
- if the player leaves, you have the tool and you can just clear the table on the players index
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.