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

Object shakes when moving to mouse coordinates?

Asked by 7 years ago
Edited 7 years ago
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?

1
mouse.TargetFilter isn't set so mouse.Target will see the desk which would cause your shaking thing I believe. Sekant 20 — 7y
0
maybe it's that it isn't anchored (i never experimented in the mouse section, only with MouseButton) GamingZacharyC 152 — 6y
0
btw lower case C in :connect is deprecated and will work in Studio but not the actual game. bearpro2 6 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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)

Ad

Answer this question