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

Why does my part's position keep going directly to the camera?

Asked by 8 years ago
Edited 8 years ago

I'm recreating the old green cylinder that used to lay directly under your mouse (you guys remember that thing?), but I have encountered a problem. When the mouse is still, the part slowly drifts toward the camera, eventually reaching it. I dislike this. I do not believe this should happen. How can I stop this? Here's the script:

game.Players.PlayerAdded:connect(function(pl)

    local part = Instance.new("Part")
    part.Parent = game.Workspace
    part.Rotation = Vector3.new(90,90,0)    
    part.BrickColor = BrickColor.new("Lime green")
    part.Material = "SmoothPlastic"
    part.Size = Vector3.new(.4,2.4,2)
    part.Shape = "Cylinder"
    part.Anchored = true
    part.CanCollide = false 

while true do
    local m = pl:GetMouse()
    part.Position = m.Hit.p
    wait()
end
end)

1 answer

Log in to vote
3
Answered by 8 years ago
Edited 8 years ago

I like that you're recreating the little green thingy, those were good days.

game.Players.PlayerAdded:connect(function(pl)

    local part = Instance.new("Part")
    part.Parent = game.Workspace
    part.Rotation = Vector3.new(90,90,0)    
    part.BrickColor = BrickColor.new("Lime green")
    part.Material = "SmoothPlastic"
    part.Size = Vector3.new(.4,2.4,2)
    part.Shape = "Cylinder"
    part.Anchored = true
    part.CanCollide = false 

while true do
    local m = pl:GetMouse()
    m.TargetFilter = part
    part.Position = m.Hit.p
    wait()
end
end)

Anyways, you had everything down pretty well it's just that the mouse was still able to tell the part was there. TargetFilter makes it so that the mouse never picks up the part. Good job on the rest though.

0
Thank you! Rodmane234 85 — 8y
Ad

Answer this question