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

How do i make OnTouch?

Asked by
funzrey 58
10 years ago

Ok ive tried this

OnTouch(game.workspace.part)
         game.workspace.part:remove()
end

I've seen pepole use connect before, But i dont understand what that does This was months ago, I edited it to explain! OnTouch(game.workspace.part) Was my attempt to think there was already a function called OnTouch i just use it and put where the part is. game.workspace.part:remove() removes that part when someone touches it.

2 answers

Log in to vote
0
Answered by
Kozero 120
10 years ago
function Hello()
local Part =Workspace.Part
Part:Destroy()
end
script.Parent.Touched:connect(Hello)

Let me explain this for you.. When The event " Touched" has been activated by anything that has touched it the connect method will run the function and Therefore the part will be deleted.

0
ty ;) funzrey 58 — 10y
0
now i can create my doors [aauto doors] funzrey 58 — 10y
0
If you need any Help message me on roblox for my skype Kozero 120 — 10y
0
i dont have skype :c funzrey 58 — 10y
0
Im Trying to make a Debounce, Hope it works well c: funzrey 58 — 10y
Ad
Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago

Part is like a table, and it has variables inside of it whose values affect how it interacts with the game world. Some of these values are functions and events, like Touched. Part.Touched is triggered whenever it is touched, and when you connect it to a function, the function is triggered whenever the part is touched.

Part.Touched:connect(function(hit)
    print(hit.." touched the part")
end)
0
I wish i could accept both ;-; funzrey 58 — 9y

Answer this question