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

I want to make touching by tool but it works when I'm touching without tool. How can I fix that?

Hello! I made a scripting that make: When door touched by tool, door anchored = false. It works but when I have a tool in invetnory and I'm touching the door by body it also works. How can I fix that?

Script: local function onTouch(doorHouse)

game.Workspace.DoorHouse.Anchored = false

end game.Workspace.DoorHouse.Touched:Connect(onTouch)

1 comment

0

You need an [if statement] in order to make sure only the tool is allowed to operate within the Touched event.

1 answer

You need a check to make sure it's a tool

if doorHouse:IsA("Tool") then
		
end

Or if just a part of the tool hits the door.

if doorHouse.Parent:IsA("Tool") then
		
end

1 comment

0

I made something like that: local Ram = game.Workspace.Ram local function onTouch(doorHouse) if doorHouse:IsA("Ram") then game.Workspace.DoorHouse.Anchored = false end game.Workspace.DoorHouse.Touched:Connect(onTouch) and output showed an error: "Workspace.AykoOfficial.Ram.Handle.LocalScript:10: 'end' expected (to close 'function' at line 3) near ''"

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