Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make brick that is following you rotate around you?

Asked by 5 years ago
Edited 5 years ago

I'm using linear interpolation (lerp) to make a part follow my character around. I want to make that brick rotate around my character as it's following me, but nothing as seemed to work. I've tried multiplying the brick's CFrame by CFrame.Angles but it would move too fast or glitch.

local Player = game:GetService("Players").LocalPlayer

repeat
    wait()
until Player.Character and Player.Character.Head

local Char = Player.Character
local Head = Char.Head

local AdminCube = {}

AdminCube.Admins = {"bubb96", "Embirius", "DiistantReality"}



function AdminCube:createCube()

    local cube = Instance.new("Part", Char)

    -- set properties
    cube.Size = Vector3.new(0.95, 1, 0.93)
    cube.Material = Enum.Material.Neon
    cube.Anchored = true
    cube.Name = "Admin Cube v0.01 by Embirius/bubb96"

    -- make the cube smooth
    cube.BackSurface, cube.BottomSurface, cube.FrontSurface, cube.LeftSurface, cube.RightSurface, cube.TopSurface
        = Enum.SurfaceType.SmoothNoOutlines, Enum.SurfaceType.SmoothNoOutlines, Enum.SurfaceType.SmoothNoOutlines, Enum.SurfaceType.SmoothNoOutlines, Enum.SurfaceType.SmoothNoOutlines,
            Enum.SurfaceType.SmoothNoOutlines

    -- physics & other loops
    game:GetService("RunService").RenderStepped:Connect(function()
        cube.CFrame = cube.CFrame:lerp(Head.CFrame, 0.1) * CFrame.new(0.5,0,0)
        wait()
        cube.CFrame = cube.CFrame * CFrame.fromEulerAnglesXYZ(0, 0.5 0) -- what i've tried

    end)

end

AdminCube:createCube()

Help would be greatly appreciated.

Answer this question