So, I want to only allow the player to exchange their tool for another one if they already have it in their inventory. I made a simple script which works, but you can just make the tool appear out of no where without having the thing you need to craft it. I don't know if i'm just being stupid because it sounds so simple but im new to programming and having difficulty.
script.Parent.Triggered:Connect(function(player)
local Pack = player.Backpack
local rs = game:GetService("ReplicatedStorage")
local Item = rs:WaitForChild("Copper")
local ItemClone = Item:Clone()
ItemClone.Parent = Pack
local RemoveItem = "Malachite Chunk"
if player.Character and player.Character:FindFirstChild(RemoveItem) and player.Character[RemoveItem]:IsA("Tool") then
player.Character[RemoveItem]:Destroy()
end
end)
This script is inside a proximity prompt, and maybe there is a way for the proximity prompt to just not show up if they don't have it in their inventory i'm thinking?

3 comments
I have tried this but it does remove it from the backpack, but not from the toolbar from the bottom. My solution was to use to check the character and it worked, but i''m just wondering if I can only allow the script to run if a certain item is in the backpack already
I've added something to my answer, check it out and get back to me if it helps you
Thank you so much it works perfectly!!!