#Scripting a safe/storage

26 messages · Page 1 of 1 (latest)

north plank
#

So basically im trying to make it to where if you have a gun or a tool in your backpack it clones onto the Ui and stuff but im not sure how to do that here is a script i just made off of scratch (may not be right)

local player = game.Players.LocalPlayer

local RS = game:GetService("ReplicatedStorage")
local GunsFrame = RS:WaitForChild("GunsFrame")
local GunsFrameClone = GunsFrame:Clone()

local SafeFrame = script.Parent

if player.Backpack:FindFirstChildWhichIsA("Tool") then
    GunsFrameClone.Parent = SafeFrame.BGInventoryFrame.InventoryFrame
    GunsFrameClone.DisplayBTN.Text = player.Backpack:FindFirstChildWhichIsA("Tool")
else
    if player.Backpack:FindFirstChildWhichIsA("Tool") == nil then
        GunsFrameClone:Destroy()
    end
end
digital dragon
#

I don’t have time to fully help you but be aware that equipped tools are stored in the player model, not in the backpack

north plank
#

I’m not talking about if they have it equipped I’m saying like if it’s just in their backpack

digital dragon
#

Oh, so like a storage thingy

#

You don’t have any events to update the script when a player loses the weapon

#

So that may be something to be aware off as well

north plank
digital dragon
#

Event

north plank
#

Alright

#

You think this would be a complex script

#

I tried using a string value to to get the tool but idk how to get multiple

digital dragon
#

I’ld say average

compact field
#

Maybe table based ?

north plank
# compact field Maybe table based ?

I thought about that like running it through a table but I was thinking if I have a bunch of guns in my game that would get tiring having to add all the guns and stuff

#

That’s why I’m tryna find a way to use the findfirstchildwhichisA

#

If people could have multiple guns and stuff should I make the clone a variable or just say Clone()

digital dragon
#

Yeah, if you will have a bigger database then just make a script to load guns from inside a map inside the RS

north plank
#

Wym

digital dragon
#

Then just have all data that goes with the guns saved somewhere as well

digital dragon
north plank
#

My guns are in serverstorage rn

digital dragon
#

In a folder or without a folder?

north plank
#

I have a few folders

#

Like shopGuns and TurfGund

#

Guns