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

How do I make an event happen when a certain part touches the part with OnTouch?

Asked by 3 years ago
Edited 3 years ago

I tried to figure this out, but it only works with humanoid. I hope I don't sound too complicated.

I didn't really insert this in the title but how do I make a data for that event so when the event happens again, the event does something different and then nothing?

code

local Part = script.Parent
Part.Parent = game.Workspace

local function onTouched(otherPart)
    print("touched")
    Part.BrickColor = BrickColor.new("Dark green")
end
Part.Touched:Connect(onTouched)
0
Do you have any code to show us? zane21225 243 — 3y
0
Can you add the current script you have that works with the humaniod to you question please? ThatDevTim 188 — 3y
0
oop ThatDevTim 188 — 3y
0
Here is a script I made: cookie_more 30 — 3y
View all comments (2 more)
0
within the function, make and if statement like this: cookie_more 30 — 3y
0
With in the function, make an if statement like this at the start of the function before and code can run, and put the code you want to run under "then": if otherPart.Name == "(Insert name of part here)" cookie_more 30 — 3y

1 answer

Log in to vote
3
Answered by 3 years ago

This can be done is one of many ways. I'm taking you only want it to work with one part(correct me if I'm wrong). And since(as of now) there is no script included with your question, I won't write it all out for you.

You(of course) need to have the function

script.Parent.OnTouched:Connect(function(part)

end)

Then you need to check if the "part"'s name is the correct name of the wanted part

if part.Name == "Desired Name Here" then
-- Code Here
end

Hope this helped!

Happy Scripting, Tim

Ad

Answer this question