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

How to make a part Archivable on touch?

Asked by
Dwayder 29
8 years ago

I want to make a part archivable on touch if the name of the person who touched it is named certain. This is what I tried but its not working :P

1function OnTouch()
2    if script.Parent.Touched.Name == "Player1"
3        then script.Parent.Parent.Part.Archivable = true
4    end
5end
0
can you include the full code pls. User#5423 17 — 8y
0
You don't even have a connect in there duddeeee Spathi 0 — 8y

1 answer

Log in to vote
1
Answered by
nanaluk01 247 Moderation Voter
8 years ago

I noticed a few things about your code.

First of all, you are not calling your function in any way, which would make it not run.

Second of all, on line 3, you have put your "then" on the wrong line, your "then" has to be on the second line.

Here is some code that should work for you:

~~~~The following is non-tested code~~~~

This script should go into the "child of the child of the part that is going to be archivable'd"

01--Since you are using "script.Parent.Parent.Part.Archivable", that's what I am going to use in this code as well.
02 
03script.Parent.Parent.Part.Touched:connect(function(hit)
04 
05    if not hit.Parent:FindFirstChild("Humanoid") then return end --If the part that touches the part, is actually a player, then we continue
06 
07    if hit.Parent.Name == "Player1" then
08 
09        script.Parent.Parent.Part.Archivable = true
10 
11    end
12 
13end)

However, tell me one thing. Why do you want it to be archivable only after a certain player has touched it?

If this answer helped you, make sure you accept my answer!

Ad

Answer this question