I am just beginning in Lua and I really need some help on how to remove an item from the StarterPack when a player steps on a brick. Also, the item is called TPTool. My game is filtering enabled and i'm not quite sure what to do.
I'm nowhere near an expert scripter, so please bare in mind with my messy script.
First you should insert a ServerScript into a brick.
local Players = game:GetService("Players") script.Parent.Touched:Connect(function(hit) --when the player touches the part local humanoid = hit.Parent:FindFirstChild("Humanoid") --finds the humanoid through the part that hit the brick, meaning that it finds the parent of the part that touched it and searches for a humanoid local player = Players:GetPlayerFromCharacter(humanoid.Parent) --gets the player through the humanoid's parent, which is the character local TPTool = player.Backpack:FindFirstChild("TPTool") --searches for the tool inside of the player's backpack if TPTool ~= nil then --basically means if the script finds the tool inside of the backpack TPTool:Destroy() --destroys the tool end end)
Might be some errors, but I'm not sure..
Try this script:
local ting = 0 function onTouched(hit) if ting == 0 then ting = 1 check = hit.Parent:FindFirstChild("Humanoid") if check ~= nil then local player = game.Players:GetPlayerFromCharacter(hit.Parent) local tptool= player.StarterGear:findFirstChild("TPTool") if tptool~= nil then player.StarterGear.TPTool:Destroy() player.Backpack.TPTool:Destroy() end end ting = 0 end end script.Parent.Touched:connect(onTouched)
Accept this answer if it worked:>.