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

i am trying to make the part look were the mouse is look but it wont how do i fix?

script.Parent.Activated:Connect(function()
    local plr = game.Players.LocalPlayer
    local mouse = plr:GetMouse()
    local char = plr.Character
    local waited = char:FindFirstChild("asdsd")
local x = Instance.new("BodyVelocity",waited)
waited.Anchored = false
x.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
x.Velocity = mouse.Hit.LookVector * 23
waited.Orientation = mouse.Hit.LookVector.Orientation
wait(2)
waited:Destroy()
end)

2 answers

✓ Accepted answer

Hi, I'm BlackOrange and I will be trying to help you out.

#Problems:#

  1. It seems like you are trying to move the part to the mouse position
  2. You have variables that could be outside, inside an event

#Solution:#

I will attempt to explain and type you a rough script of what you are trying to do.

-- Assuming this is a local script
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local Char = plr.Character or plr.CharacterAdded:Wait()
local Part = Char:WaitForChild('asdsd') -- the part that would look at the mouse

script.Parent.Activiated:Connect(function() -- activated event
	Part.CFrame.lookVector = Mouse.Hit.lookVector -- Changed rotation
end)

I do not know if this script works since I haven't worked with cframe for a while. But this is what you should be doing. Now since this is NOT a loop if you want it to continuously to rotate to face the mouse then you would have to add a loop OR spam to trigger to event multiple times.

Hopefully this helped.

Best of luck developer!

script.Parent.Activated:Connect(function()
	local plr = game.Players.LocalPlayer
	local mouse = plr:GetMouse()
	local char = plr.Character
	local waited = char:FindFirstChild("asdsd")
	local x = Instance.new("BodyVelocity",waited)
	waited.Anchored = false
	x.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	x.Velocity = mouse.Hit.LookVector * 23
	waited.CFrame = CFrame.new(waited.CFrame.Position, mouse.Hit.LookVector)
	wait(2)
	waited:Destroy()
end)

hopefully this helps ^_^

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