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

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

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

✓ Accepted answer

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.

1 comment

0

Thank you!

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