Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

if player have tool, cancollide equal false?

Asked by
0msh 333 Moderation Voter
7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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

0
Works! Thanks! 0msh 333 — 7y
0
Glad it helped. If you don't mind, I would appreciate upvote and accept answer :) dpark19285 375 — 7y
0
did! 0msh 333 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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

Answer this question