I'm not asking for a script or anything (although it would be nice), where would I look if I wanted to create a brick that unequips the tools you're holding when you touch it? Thanks!
So to get started you want to check when the part gets hit, to do this you can do
script.Parent.Touched:connect(function(hit) end)
and the hit in between the () in front of the function will detect what hit it, so to detect if its a player you want to do
local human = hit.Parent:FindFirstChild("Humanoid") if human then print("Its human") end
So now we need to check if the player has the tool, so just the same as we did with the humanoid
local Tool = hit.Parent:FindFirstChild("ToolName") if Tool then print("Found tool") end
so if it found the tool is should print Found tool, now we need to get the player and its backpack, to get the player just do
local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then print("Found player!") end
now that we have the player we need to find the backpack which is in the player and i you need to define the tool after the part where it finds the humanoif, to do so just add a simple line
local Backpack = player:FindFirstChild("Backpack") if Backpack then print("Found backpack") end
now if it found the backpack we can insert the tool into the backpack by just simply saying
Tool.Parent = Backpack
and that should do it, here is all the code:
script.Parent.Touched:connect(function(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human then print("Its human") local Tool = hit.Parent:FindFirstChild("ToolName") if Tool then print("Found tool") end local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then print("Found player!") local Backpack = player:FindFirstChild("Backpack") if Backpack then print("Found backpack") Tool.Parent = Backpack end end end end)
So i really hope this helped you out, i do suggest checking out the wiki it can really help you learn scripting, Upvote and select as answer if it helped, comment on here or message me if you have and questions, user is EndorsedScripter