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

Object shakes when moving to mouse coordinates?

mouse.Move:connect(function()
	if mouse.Target then
	if mouse.Target.Name ~= "floorpart" then
	while wait() do
			workspace.Desk1:SetPrimaryPartCFrame(CFrame.new(mouse.Hit.p.X-mouse.Hit.p.X%1,1.5,mouse.Hit.p.Z-mouse.Hit.p.Z%1))
	end
	end
	end
end)

When I move the mouse, the object starts to shake. wherein. Although if you move the mouse very close to the player, then everything is okay. Whats wrong?

3 comments

1

mouse.TargetFilter isn't set so mouse.Target will see the desk which would cause your shaking thing I believe.

0

maybe it's that it isn't anchored (i never experimented in the mouse section, only with MouseButton)

0

btw lower case C in :connect is deprecated and will work in Studio but not the actual game.

1 answer

Make sure workspace:FindFirstChild("Desk1") is anchored,

Also :connect is deprecated use :Connect instead.

Here is the fixed script:

mouse.Move:connect(function()
    if mouse.Target then
    if mouse.Target.Name ~= "floorpart" then
    local desk1 = game:GetService("Workspace"):FindFirstChild("Desk1")
    desk1["Anchored"] = true
    while wait() do
            desk1:SetPrimaryPartCFrame(CFrame.new(mouse.Hit.p.X-mouse.Hit.p.X%1,1.5,mouse.Hit.p.Z-mouse.Hit.p.Z%1))
    end
    end
    end
end)

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