Tween Plays on Touch only works sometimes. Why?
Asked by
5 years ago Edited 5 years ago
Hello everyone!
I was working on my game today and it's a little bit like an obby.
I have one platform that would appear shaky and will sink into lava upon touch.
How I did it was by having two tweens (Tween2 and Tween3) to shake the platform. And upon touch, it would play another tween (Tween4) to go down. After a few seconds, it would play a tween (Tween1) to go back up to the original position.
Sorry if the order of the tween names may be a little confusing.
Anyways, the issue is that when I touch the part, only sometimes does it stop shaking, does go down and back up and continue shaking. Sometimes it just doesn't register me from touching it.
Script is placed in the platform.
Here is my code:
01 | local stick = script.Parent |
02 | local touched = script.Parent.numv - a number value. 0 is no touch and 1 is touch. |
03 | local TweenService = game:GetService( "TweenService" ) |
04 | local TweenInf = TweenInfo.new( 1 ) |
06 | goal 1. Position = Vector 3. new(- 141.89 , 32.927 , 10.753 ) |
08 | goal 2. Position = Vector 3. new(- 140.49 , 31.527 , 9.353 ) |
10 | goal 3. Position = Vector 3. new(- 142.99 , 34.027 , 11.853 ) |
12 | goal 4. Position = Vector 3. new(- 141.89 , 10 , 10.753 ) |
14 | local Tween 1 = TweenService:Create(stick, TweenInf, goal 1 ) |
15 | local Tween 2 = TweenService:Create(stick, TweenInf, goal 2 ) |
16 | local Tween 3 = TweenService:Create(stick, TweenInf, goal 3 ) |
17 | local Tween 4 = TweenService:Create(stick, TweenInf, goal 4 ) |
23 | script.Parent.Touched:Connect( function () |
42 | touched.Changed:Connect( function () |
43 | while touched.Value = = 0 do |