How do i move my part forward in my script

local tool = script.Parent

tool.Equipped:Connect(function (mouse)

mouse.Button1Down:Connect(function()
	local function createBrick(position, rotation)
		local shoot = game.ReplicatedStorage.wandmagic.shoot:Clone()
		shoot.Size = Vector3.new(1, 1, 1)
		shoot.Position = position
		shoot.Orientation = rotation
		shoot.Anchored = true
		shoot.CanCollide = false
		shoot.Parent = workspace
		print("Created")
	end
	tool.Activated:Connect(function()
local player = game.Players.LocalPlayer
local character = player.Character
local rootPart = character.HumanoidRootPart
if rootPart then
	createBrick(rootPart.Position, rootPart.Orientation)
end
print("Activated")

end)
end)
end)

You can add CFrame at a certain direction to move forward. I believe the x-axis is where the part moves forward, but try z as well.

1 Like

thx but im confused whats the CFrame code

How I would describe CFrame is like a position based on the vector of the model. So you can imagine it in a 3d space where the orientation represents the axis on the xyz axis. More information here CFrame | Roblox Creator Documentation

1 Like

There a many examples of how to make a bullet style object. Just look at a script from some other tool that shoots. You have a weath of scripts to look at and learn from here with the Studio’s Toolbox.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.