I want to save tools to StarterGear after pickup or just have the tools come back on death or character reloaded and also have them disappear when you leave the game. Basically like the game Stands Awakening (I know other games have it I’ve just been playing this one recently). Thanks!
Are you wanting to save them like as in a DataStore of some sort?
No, I don’t want it to save after you leave, just after death or the character reloads. So I don’t think a DataStore would be necessary.
Ah, I gotcha
Well, this is a unique topic on how to approach this Maybe 1 method you could possibly try, is using a
bool
to detect when the tool first gets equipped to clone into the Player’s StarterGear?
local PickedUp = false
local Tool = script.Parent
Tool.Equipped:Connect(function()
local Character = Tool.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
if Player and not PickedUp then
PickedUp = true
local SaveTool = Tool:Clone()
SaveTool.Parent = Player.StarterGear
end
end)
This is obviously just an example & assumption on what you could potentially do?
It could work since tools are automatically equipped on pickup, it’s just I would rather have a method that does it on pickup rather then an action that happens because of pickup. Also, does putting a gear into StarterGear automatically put it into the hotbar too? Thanks for the help!
Script in starter player scripts:
local plr = script.Parent.Parent
plr.Backpack.ChildAdded:Connect(function(child)
if child:IsA("Tool") then
child:Clone().Parent = plr.StarterGear
end
end)
But would this work when picking up the tool and it goes into the hotbar? Cause something I’ve noticed is that if it goes into your hotbar it gets attached to your player and not the backpack. Thanks!
EDIT: I realize I may be doing something wrong so please tell me if I am.
Just try it out. It looks for when a tool gets added into the backpack(when something is picked up) and will add that tool to the starter gear
This won’t work. I am looking for another way.
Yeah I was going to say that. Thanks for the help though!
That would only apply if a Character were to respawn, or if a tool was already parented inside the StarterPack
@AC_Starmarine You could literally use that same script, but a bit modified from the server side instead in ServerScrtipService
game.Players.PlayerAdded:Connect(function(plr)
plr.Backpack.ChildAdded:Connect(function(child)
if child:IsA("Tool") then
child:Clone().Parent = plr.StarterGear
end
end)
end)
Yeah I was going to say that I used a server script instead of a local script since the client could just modify what they have and send that to the server.
Also, that script doesn’t work. Just saying it just incase you didn’t see the previous post. It’s fine though! Thanks!
Hm, are you getting any errors at all? If not, could you possibly reference the Character instead?
Try this script in starter character scripts:
local players = game:GetService("Players")
local player = players:GetPlayerFromCharacter(script.Parent)
local starterGear = player.StarterGear
local char = script.Parent
char.ChildAdded:Connect(function(child)
if child:IsA("Tool") and not starterGear:FindFirstChild(child.Name) then
child.Archivable = true
child:Clone().Parent = starterGear
print("tool added to starter gear")
end
end)
The next problem is that I also I want to save things in the backpack. Thanks!
So the new script I sent work for saving picked up items?
Yes it does work! Now I just need to make it work with backpack.
Try this update version of my script(in startercharacterscripts):
local char = script.Parent
local players = game:GetService("Players")
local player = players:GetPlayerFromCharacter(char)
local starterGear = player.StarterGear
char.ChildAdded:Connect(function(child)
if child:IsA("Tool") and not starterGear:FindFirstChild(child.Name) then
child.Archivable = true
child:Clone().Parent = starterGear
print("tool added to starter gear")
end
end)
player.Backpack.ChildAdded:Connect(function(child)
if child:IsA("Tool") and not starterGear:FindFirstChild(child.Name) then
child.Archivable = true
child:Clone().Parent = starterGear
print("tool added to starter gear")
end
end)
The only problem with this is that they can simply add they item back and forth between the backpack and character to dupe it. Honestly using a table or datastore temporally might be the best option unless someone comes up with a better idea. Thanks for the help though!