Alright everyone so i have been working on this code but cant seem to get it what I want to do is make a painting where if you click it, it moves side to side the the roblox game break in, thanks in advance.
local originalOrientation = painting.Orientation
local shakeDuration = 0.4
local shakeIntensity = 0.2 -- Adjust this value for the desired intensity
local debounce = false
local function ShakePainting()
if debounce then
return
end
debounce = true
local shakeTweenInfo = TweenInfo.new(
shakeDuration,
Enum.EasingStyle.Sine, -- Smooth sine easing for side-to-side shake
Enum.EasingDirection.Out
)
local shakeTween = game:GetService("TweenService"):Create(painting, shakeTweenInfo, {
Orientation = originalOrientation + Vector3.new(shakeIntensity, 0, 0)
})
shakeTween:Play()
shakeTween.Completed:Wait()
-- Reset orientation
painting.Orientation = originalOrientation
debounce = false
end
local clickDetector = painting:FindFirstChild("ClickDetector")
if not clickDetector then
clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = painting
end
clickDetector.MouseClick:Connect(ShakePainting)