Reputation: 17
I am working for a Airport in Roblox and I need a script that when I click on a button, the script check if I have a specific tools in my inventory (In this case a suitcase). If I got the suitcase, the player who click on the button get the suitcase removed from his inventory. I don't want that the entire inventory get removed, only the tool. I want also that the suitcase respawn on a specific place. (On the conveyor.(Please, use X,Y,Z to respawning the suitcase)) I know this isn't a easy script but if someone know how to do it, I will be really happy.
Upvotes: 1
Views: 3033
Reputation: 449
All you need to do is check if the suitcase is nil
, which is simple:
local suitcase = player.Backpack:FindFirstChild("Suitcase")
if suitcase == nil then
--suitcase is nil!
else
--suitcase is not nil!
end
I used the FindFirstChild()
function, which finds the first child of whatever's calling it specified, to see if the suitcase was nil
or not. If there is no such child parented to the caller, FindFirstChild()
returns nil
.
Upvotes: 2