gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)
Make a roblox studio script that spawns a part that chases you every where.
- User
Make a roblox studio script that spawns a part that chases you every where.
- 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:
- Create a new Script inside the Roblox Studio.
- Copy and paste the above script into the newly created Script.
- Adjust the initial position, speed, and any other property values as necessary.
- 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.