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)
Hi, I'm BlackOrange and I will be trying to help you out.
- It seems like you are trying to move the part to the mouse position
- You have variables that could be outside, inside an event
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 ^_^