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

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

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)

6 comments

0

Do you have any code to show us?

0

Can you add the current script you have that works with the humaniod to you question please?

0

oop

0

Here is a script I made:

0

within the function, make and if statement like this:

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)"

1 answer

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

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