Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i fix when a mouse moving a part that part dose not com up at screen?

Asked by 5 years ago
local player = game.Players.LocalPlayer 
local mouse = player:GetMouse()
local toggle = false

mouse.KeyDown:connect(function(key)
 if not toggle and key == "r" then
local i =  Instance.new("Part",workspace)
i.Size = Vector3.new(14.53, 11.41, 1.59)
i.Anchored = true
while true do
    wait()
    i.Position = mouse.Hit.Position
end

 end
end)

1 answer

Log in to vote
2
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

1.) KeyDown is deprecated, use UserInputService or ContextActionService.

2.) The way mouse.Hit is calculated is with a ray, which is the UnitRay property, and gets the position where the ray and a BasePart instersect. This is why the part comes up to your camera. Your solution is to set the Mouse's TargetFilter to the part you want to move.

mouse.TargetFilter = i
0
Thank YOU!!!!!!! helleric -3 — 5y
Ad

Answer this question