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

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

Asked by 4 years ago

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)

0
You need an [if statement] in order to make sure only the tool is allowed to operate within the Touched event. Serpawh -4 — 4y

1 answer

Log in to vote
0
Answered by
Kami_Yo 72
4 years ago
Edited 4 years ago

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
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 '<eof>'" AykoOfficial -6 — 4y
Ad

Answer this question