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:
local stick = script.Parent -- the platform local touched = script.Parent.numv - a number value. 0 is no touch and 1 is touch. local TweenService = game:GetService("TweenService") -- Get TweenService local TweenInf = TweenInfo.new(1) -- The TweenInfo local goal1 = {} goal1.Position = Vector3.new(-141.89, 32.927, 10.753) -- The Goal For Tween1 local goal2 = {} goal2.Position = Vector3.new(-140.49, 31.527, 9.353) -- The Goal For Tween2 local goal3 = {} goal3.Position = Vector3.new(-142.99, 34.027, 11.853) -- The Goal For Tween3 local goal4 = {} goal4.Position = Vector3.new(-141.89, 10, 10.753) -- The Goal For Tween4 local Tween1 = TweenService:Create(stick, TweenInf, goal1) -- Create the tween local Tween2 = TweenService:Create(stick, TweenInf, goal2) -- Create the tween local Tween3 = TweenService:Create(stick, TweenInf, goal3) -- Create the tween local Tween4 = TweenService:Create(stick, TweenInf, goal4) -- Create the tween local poop = false -- debounce script.Parent.Touched:Connect(function() -- When the platform is touched. print("bruh") if poop==false then -- Check the debounce print("xddd") poop = true -- Change the debounce touched.Value = 1 -- Change the touched value to true (in numbers) Tween2:Pause() -- Pause the Tween Tween3:Pause() -- Pause the Tween Tween4:Play() -- Play the Tween that Sinks wait(5) poop = false -- Change the debounce Tween1:Play() -- Play the Tween that goes back to it's original position touched.Value = 0 -- Change the touched value to false print("ended") end end end) touched.Changed:Connect(function() while touched.Value==0 do Tween2:Play() wait() Tween3:Play() wait() end end) wait() touched.Value = 0