How do I make the UI move while the character is moving (Sway Effect)

You can write your topic however you want, but you need to answer these questions:

  1. **Hello, Does anyone knows how to make the UI move, while the character is moving. Look into the video. - Credits: ened.

(health bar function added - YouTube)

**I have tried this script:

 local button = script.Parent -- your button here
local originalPosition = button.Position -- used to revert button to it's original position, after the player hovers off the button
local absolutePosition = button.AbsolutePosition -- used to determine button position while shaking
local Player = game:GetService("RunService")

local shakeIntensity = 0.9 -- how far, in pixels, the button will shake
local hovering

Player.RenderStepped:Connect(function()
	hovering = true

	while hovering do
		wait()

		local desiredPosition = absolutePosition + Vector2.new(math.random(-shakeIntensity, shakeIntensity), math.random(-shakeIntensity, shakeIntensity))
		local newPosition = (desiredPosition - button.Parent.AbsolutePosition) -- subtract the parent's position from the desired position to get its offset
		button.Position = UDim2.fromOffset(newPosition.X, newPosition.Y)
	end

	button.Position = originalPosition -- revert button to it's original position
end)

Player.RenderStepped:Connect(function()
	hovering = false
end)

The problem that it’s shaking not moving.

If you have any solutions please post it, Thank You.

This might be helpful

It doesn’t work; Thank you for your help though!

This will help you

Thank You! Sorry for replying late.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.