Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

if player have tool, cancollide equal false?

Sorry if the title confused you, but I can't think about another title. I am a beginner at scripting. How can I make a script that I'll put inside of a part that player can go through when they have certain tool?

2 answers

✓ Accepted answer

Let me try to explain this a bit in-depth since you said you're new to scripting.

Correct me if I'm wrong, but I'm assuming that you're talking about a script that checks if a player has a certain tool, and if so, sets a part's CanCollide property to false if the player touches it. This is a fairly simple thing to do; but first, you should know that tools are added to the player's character in the Workspace whenever they equip it. Using this, you could make a script that uses the part's Touched event to search if the tool is found inside the player's character (This script assumes that the script is inside the part):

local toolName = "Tool" --The tool's name
local part = script.Parent --Your part's directory

part.Touched:connect(function(hit)
	local tool = hit.Parent:FindFirstChild(toolName) --Check for the tool
	if tool then
		part.CanCollide = false
		--Add other things you might want the part to do
	end
end)

However, like I mentioned before, the tool is only added to the player's character when it is equipped, so this script would only work if the player touches the part while he/she has already equipped the tool.

Hope this helped and everything made sense

3 comments

0

Works! Thanks!

0

Glad it helped. If you don't mind, I would appreciate upvote and accept answer :)

0

did!

Im also a beginner but i learned abit, ill try my best ok C: and also you needa put a localscript in startergui and put this script inside it

game.Players.LocalPlayer.Backpack:WaitForChild("Tool") -- write tool name where it says Tool
game.Workspace.Part.CanCollide = false -- Write part name where it says part

This discussion is preserved as it was. New answers, comments, and votes are closed.