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

How do I make this script trigger on player touch?

Asked by
par1d 19
5 years ago

Hey, I have this script that makes a part move up and down however I would like the script to start when I have touched the part? How would I do this? Any help would be great ! :D

Here is the script:

01for i=1, 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 1 do
02distance = 250
03 
04for i = 0, distance do
05script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0,0.2, 0)
06wait()
07end
08 
09 
10for i = 0, distance do
11script.Parent.CFrame = script.Parent.CFrame-Vector3.new(0,0.2,0)
12wait()
13end
14end
0
just use a while loop lol Fifkee 2017 — 5y
0
or do math.huge Mawfix 15 — 5y
0
dude how hard is it to use google? like fr EmbeddedHorror 299 — 5y

1 answer

Log in to vote
1
Answered by
enes223 327 Moderation Voter
5 years ago
Edited 5 years ago

Script in a part (not localscript):

1script.Parent.Touched:connect(function(hit)
2local victim = hit.Parent
3--script here
4end)
Ad

Answer this question