I was programming a Magic system for my game, when I realized; I have literally no clue how to get a brick to actually move towards the mouse. I understand mouse Targets, hits, and the like, but I've tried methods like :MoveTo() and BodyVelocity, but neither of them worked very well.
(This section is for people who don't understand what I'm asking) All in all, I need a brick to spawn ontop of the Player Character's UpperTorso, and then move to the mouse's Target.
If any of you could give me a point in the right direction, that would be great!
EDIT: Also, here's the code I'm using, if that helps in any way:
mouse.KeyDown:connect(function(key)
if (key == 'q') then
-- This script freezes the player midair, and has them turn to face the mouse.
RotateRootPart = true
local RootPart = character.HumanoidRootPart
RootPart.Anchored = true
local mouse = player:GetMouse()
mouse.Move:connect(function()
if (RotateRootPart == true) then
RootPart.CFrame = CFrame.new(RootPart.Position, mouse.Hit.p)
elseif (RotateRootPart == false) then
end
end)
wait(1.5)
local NewGroup = Instance.new('Model', game.Workspace)
local BlindingFog = Instance.new('Part', NewGroup)
BlindingFog.TopSurface = 'Smooth'
BlindingFog.BottomSurface = 'Smooth'
BlindingFog.CanCollide = false
BlindingFog.Position = character.UpperTorso.Position
wait(1.5)
RotateRootPart = false -- Disables the effect of turning to face the mouse.
RootPart.Anchored = false -- Drops the player.
end
end)

2 comments
KeyDown is deprecated. Don't use it.
Oof. KK.