I'd be happy to help you create a button with hover tilt effects and click animations with sound! Since you haven't shared your existing script, I'll create a complete example that you can adapt:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive Button</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}
.button-container {
perspective: 1000px;
}
.interactive-button {
padding: 20px 40px;
font-size: 18px;
font-weight: bold;
color: white;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
border-radius: 12px;
cursor: pointer;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
transform-style: preserve-3d;
position: relative;
overflow: hidden;
}
.interactive-button:hover {
transform: rotateX(-10deg) rotateY(10deg) scale(1.05);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}
.interactive-button:active {
transform: scale(0.95);
}
/* Ripple effect for click animation */
.ripple {
position: absolute;
border-radius: 50%;
background-color: rgba(255, 255, 255, 0.6);
transform: scale(0);
animation: ripple-animation 0.6s ease-out;
}
@keyframes ripple-animation {
to {
transform: scale(4);
opacity: 0;
}
}
/* Success animation */
.button-success {
animation: success-pulse 0.5s ease-out;
}
@keyframes success-pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
</style>
</head>
<body>
<div class="button-container">
<button class="interactive-button" id="myButton">
Click Me!
</button>
</div>
<script>
const button = document.getElementById('myButton');
// Create audio element for sound effect
const clickSound = new Audio('data:audio/wav;base64,UklGRnoGAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQoGAACBhYqFbF1fdJivrJBhNjVgodDbq2EcBj+a2/LDciUFLIHO8tiJNwgZaLvt559NEAxQp+PwtmMcBjiR1/LMeSwFJHfH8N2QQAoUXrTp66hVFApGn+DyvmwhBSuBzvLXiTYIG2m98OScTgwOUarm7blmFgU7k9n1unEiBC13yO/eizEIHWq+8+OWT' +
'AkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAEN' +
'Vqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkP' +
'Vqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OW' +
'TAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGgU3k9n1unEiBC13yO/eizEIHWq+8+OWTAkPVqzq67VlGAU3k9n1unEiBC13yO/eizEI');
// Mouse move handler for dynamic tilt
button.addEventListener('mousemove', (e) => {
const rect = button.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const angleX = (y - centerY) / centerY * -10;
const angleY = (x - centerX) / centerX * 10;
button.style.transform = `rotateX(${angleX}deg) rotateY(${angleY}deg) scale(1.05)`;
});
// Reset tilt on mouse leave
button.addEventListener('mouseleave', () => {
button.style.transform = 'rotateX(0) rotateY(0) scale(1)';
});
// Click handler for sound and animation
button.addEventListener('click', (e) => {
// Play sound effect
clickSound.currentTime = 0;
clickSound.play().catch(error => {
console.log('Sound play failed:', error);
});
// Create ripple effect
const ripple = document.createElement('span');
ripple.classList.add('ripple');
const rect = button.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.width = ripple.style.height = size + 'px';
ripple.style.left = x + 'px';
ripple.style.top = y + 'px';
button.appendChild(ripple);
// Add success animation
button.classList.add('button-success');
// Clean up
setTimeout(() => {
ripple.remove();
button.classList.remove('button-success');
}, 600);
});
</script>
</body>
</html>
This script includes:
- Hover Tilt Effect: The button tilts based on mouse position, creating a 3D effect
- Click Sound: Uses a base64-encoded sound (you can replace with your own sound file)
- Click Animation: Includes both a ripple effect and a pulse animation
To customize this further:
- Replace the base64 sound with your own by using:
new Audio('path/to/your/sound.mp3')
- Adjust the tilt angles by changing the multipliers in the
mousemove event
- Modify colors, sizes, and animation durations in the CSS
- Add more complex animations or effects as needed
Would you like me to modify any specific part of this implementation or adapt it to work with your existing code?
-- Advanced version with gradient-based 3D effect
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local button = script.Parent
local player = Players.LocalPlayer
local mouse = player:GetMouse()
-- Create UIGradient for 3D effect
local gradient = Instance.new("UIGradient")
gradient.Parent = button
-- Create sound
local clickSound = Instance.new("Sound")
clickSound.SoundId = "rbxassetid://9116267082" -- Change to your sound ID
clickSound.Volume = 0.5
clickSound.Parent = button
-- Create drop shadow frame
local shadow = Instance.new("Frame")
shadow.Name = "Shadow"
shadow.Size = UDim2.new(1, 10, 1, 10)
shadow.Position = UDim2.new(0, -5, 0, -5)
shadow.BackgroundColor3 = Color3.new(0, 0, 0)
shadow.BackgroundTransparency = 0.7
shadow.ZIndex = button.ZIndex - 1
shadow.Parent = button.Parent
local shadowCorner = Instance.new("UICorner")
shadowCorner.CornerRadius = UDim.new(0, 12)
shadowCorner.Parent = shadow
-- Move button to front
button.ZIndex = 2
local isHovering = false
local originalSize = button.Size
local originalShadowPos = shadow.Position
-- Hover effect
button.MouseEnter:Connect(function()
isHovering = true
-- Animate button scale
TweenService:Create(button, TweenInfo.new(0.2, Enum.EasingStyle.Quad), {
Size = UDim2.new(originalSize.X.Scale * 1.1, originalSize.X.Offset * 1.1,
originalSize.Y.Scale * 1.1, originalSize.Y.Offset * 1.1)
}):Play()
-- Animate shadow
TweenService:Create(shadow, TweenInfo.new(0.2, Enum.EasingStyle.Quad), {
Position = UDim2.new(0, -8, 0, -8),
Size = UDim2.new(1, 16, 1, 16)
}):Play()
end)
button.MouseLeave:Connect(function()
isHovering = false
-- Reset button
TweenService:Create(button, TweenInfo.new(0.3, Enum.EasingStyle.Quad), {
Size = originalSize
}):Play()
-- Reset gradient
TweenService:Create(gradient, TweenInfo.new(0.3), {
Rotation = 0
}):Play()
-- Reset shadow
TweenService:Create(shadow, TweenInfo.new(0.3, Enum.EasingStyle.Quad), {
Position = originalShadowPos,
Size = UDim2.new(1, 10, 1, 10)
}):Play()
end)
-- Track mouse for tilt effect
mouse.Move:Connect(function()
if not isHovering then return end
local buttonPos = button.AbsolutePosition
local buttonSize = button.AbsoluteSize
local centerX = buttonPos.X + buttonSize.X / 2
local centerY = buttonPos.Y + buttonSize.Y / 2
local mouseX = mouse.X - centerX
local mouseY = mouse.Y - centerY
-- Calculate gradient rotation for 3D effect
local angle = math.deg(math.atan2(mouseY, mouseX)) + 90
TweenService:Create(gradient, TweenInfo.new(0.1), {
Rotation = angle
}):Play()
end)
-- Click effect
button.MouseButton1Click:Connect(function()
-- Play sound
clickSound:Play()
-- Punch animation
local punchTween = TweenService:Create(button,
TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
Size = UDim2.new(originalSize.X.Scale * 0.95, originalSize.X.Offset * 0.95,
originalSize.Y.Scale * 0.95, originalSize.Y.Offset * 0.95)
})
punchTween:Play()
punchTween.Completed:Connect(function()
TweenService:Create(button,
TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {
Size = originalSize
}):Play()
end)
-- Flash effect
local originalTransparency = button.BackgroundTransparency
button.BackgroundTransparency = 0.5
TweenService:Create(button, TweenInfo.new(0.3), {
BackgroundTransparency = originalTransparency
}):Play()
end)