Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

Make a roblox studio script that spawns a part that chases you every where.

  1. User

    Make a roblox studio script that spawns a part that chases you every where.

  2. Assistant

    Here's an example Roblox Studio script that spawns a part that chases the player character around:

    -- Create a new part
    local chasePart = Instance.new("Part")
    chasePart.BrickColor = BrickColor.new("Bright red")
    chasePart.Size = Vector3.new(5, 5, 5)
    chasePart.Anchored = true
    chasePart.CanCollide = true
    
    -- Function to calculate the direction towards the target
    local function getDirection(target, origin)
        return (target.Position - origin.Position).unit
    end
    
    -- Function to move the chasing part towards the player
    local function chasePlayer()
        while true do
            local player = game.Players.LocalPlayer -- Change to your player reference if not using a LocalScript
            local playerCharacter = player.Character or player.CharacterAdded:Wait()
            
            local humanoidRootPart = playerCharacter:WaitForChild("HumanoidRootPart")
            
            local moveDirection = getDirection(humanoidRootPart, chasePart)
            chasePart.CFrame = chasePart.CFrame + (moveDirection * 5) -- Change the speed as needed
            
            wait(0.1) -- Adjust the delay as needed
        end
    end
    
    -- Spawn the chasing part in the workspace
    chasePart.CFrame = CFrame.new(Vector3.new(0, 5, 0)) -- Change the initial position as needed
    chasePart.Parent = game.Workspace
    
    -- Start chasing the player
    chasePlayer()
    

    To use this script:

    1. Create a new Script inside the Roblox Studio.
    2. Copy and paste the above script into the newly created Script.
    3. Adjust the initial position, speed, and any other property values as necessary.
    4. Test the script by running the game or play it in Roblox Studio.

    Please note that this script assumes you are running it in a LocalScript in a player-controlled character. If you are controlling the character from the server-side or in a different context, you may need to adjust the code accordingly.