Here is my script.
01 | local part 1 = nil |
02 | script.Parent.RemoteEvent.OnServerEvent:Connect( function (LPx 1 ) |
03 | if LPx 1. Character.Humanoid then |
04 | script.Parent.Wedge.Touched:Connect( function (xy) |
05 | if part 1 ~ = nil then |
06 | print ( 'hi' ) --it is supposed to print it only once but instead it do it like 50 times |
07 | end |
08 | part 1 = xy.Parent |
09 | end ) |
10 | wait(. 5 ) |
11 | part 1 = nil |
12 | end |
13 | end ) |
How do i make the touch function remote only once not 9999 times? note that that script is undone yet.
Try disconnecting the event after the part is touched.
1 | connection = script.Parent.Wedge.Touched:Connect( function (xy) |
2 | if part 1 then |
3 | print ( "Part touched" ) |
4 | end |
5 |
6 | part 1 = xy.Parent |
7 |
8 | connection:Disconnect() |
9 | end ) |