Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a part move to a certain position?

So I'm making an auto turret that spawns in a bullet every second, and fires the bullet toward the direction of the nearest NPC. However, I can figure out how to do this. I've made so many scripts attempting to solve this problem that It would be useless to show you them (as none of them worked in any way). So, how would I do this? Basically, this is the script I keep using as a start point:

local Part = script.Parent
local newPos = Part.Position + game.Workspace.Base.target.Position 
local Time = 1
local Increment = 0.5 
local Debounce = false
 
local Diff = newPos - Part.Position
local Mag = Diff.magnitude 
local Direction = CFrame.new(newPos).lookVector
 
	for n = 0, Mag, Increment do
		Part.CFrame = Part.CFrame + (Direction * Increment)
		wait( (Time/Mag) * Increment )
	end

The script is set to aim at a part named "target". The bullet will move when it spawns in, however it only moves directly forward, it doesn't move towards the target. Help?

NOTE: The script that moves the bullet is in the bullet itself, not in the turret (don't ask me why, I just kinda made it that way for some reason). All the script really does is move the bullet in a certain direction until it reaches its destination.

1 answer

i suggest try to do it with the turret and that might work

This discussion is preserved as it was. New answers, comments, and votes are closed.