New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
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 3 months 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 — 3mo

1 answer

Log in to vote
0
Answered by
Kami_Yo 67
3 months ago
Edited 3 months 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 — 3mo
Ad

Answer this question