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

Part that moves with the mouse unexpectedly flies towards screen?

local plr = game.Players.LocalPlayer

local mouse = plr:GetMouse()

local copy = game.ReplicatedFirst.GhostParts.Wall1Ghost:Clone()

copy.Parent = game.Workspace

  

mouse.Move:Connect(function()

local position = Vector2.new(mouse.X, mouse.Y)

local size = Vector2.new(mouse.ViewSizeX, mouse.ViewSizeY)

local normalizedposition = position / size

copy.Position = mouse.Hit.p

end)

the part moves with the mouse like its supposed to but something weird happens. when I move the mouse the part moves closer and closer to my screen until it goes through it. after that it flies back to were it was originally before. this is really annoying as the part just keeps moving towards me over and over.

1 comment

0

mouse.Hit becomes where the part is

1 answer

✓ Accepted answer

What you'll need to use is Mouse.TargetFilter or fire your own ray.

I'd suggest you use Mouse.TargetFilter since its easier. Mouse.TargetFilter makes the mouse ignore all of an object's descendants.

mouse.TargetFilter = copy

1 comment

0

thanks

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