local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local hat = game.Workspace:WaitForChild("Hat") -- Replace with the name of your hat local head = character:WaitForChild("Head") -- Parameters local radius = 5 -- Orbit radius local speed = 1 -- Speed of the orbit local offset = Vector3.new(0, 5, 0) -- Adjust the Y offset if you want the hat higher or lower -- Variables for controlling the orbit local angle = 0 local orbiting = true local mode = "orbit" -- Default mode is 'orbit' -- Function to handle mode changes local function setMode(newMode) mode = newMode print("Mode changed to: " .. mode) end -- Main loop to animate the hat while true do if mode == "orbit" then -- Orbit Mode local x = math.cos(angle) * radius local z = math.sin(angle) * radius hat.CFrame = head.CFrame * CFrame.new(x, offset.Y, z) angle = angle + speed * math.rad(1) elseif mode == "bounce" then -- Bounce Mode (Vertical bounce up and down) local time = tick() local y = math.sin(time * speed) * 5 -- Change '5' to control bounce height hat.CFrame = head.CFrame * CFrame.new(0, offset.Y + y, 0) elseif mode == "spin" then -- Spin Mode (Spin around player's head) local time = tick() local rotation = math.rad(time * 100) -- Adjust speed of spinning hat.CFrame = head.CFrame * CFrame.Angles(0, rotation, 0) * CFrame.new(0, offset.Y, 5) elseif mode == "hover" then -- Hover Mode (Hat floats above the head) hat.CFrame = head.CFrame * CFrame.new(0, offset.Y, 0) -- Just keep the hat above the head end -- Wait for the next frame wait(0.03) -- ~30 frames per second end -- Listen for user input to change mode local function listenForCommands() while true do local userInput = player.PlayerGui:WaitForChild("TextBox").Text -- Assuming you have a TextBox for commands -- Check if user typed a valid mode if userInput:lower() == "mode 8" then setMode("spin") elseif userInput:lower() == "mode 1" then setMode("orbit") elseif userInput:lower() == "mode 2" then setMode("bounce") elseif userInput:lower() == "mode 3" then setMode("hover") end