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

Item / Building Placement (?)

Asked by 7 years ago

I've scoured the internet for info on the programming of a placement system. I can't provide any code (I didn't find anything and have no clue how to program this), but if anyone could help me or point me in the right direction, that would be great.

Explanation is, I wanted to program a script that would create a part that would follow your mouse until you clicked the LMB. It would then immediately stop and stay in the position you left it in.

Sorry for the inconvenience.

(Don't know why I need to add this, but... Im not a beginner.)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

What I think would be useful would be the Mouse object.

It has a few things that would help you:

  • Player:GetMouse() (returns a Mouse object)
  • Mouse.Move (event that fires when the player moves their mouse)
  • Mouse.Hit (CFrame property that is the point that the player's mouse is 'touching')
  • Mouse.Target (BasePart property that is the part the mouse is 'touching')
  • Mouse.TargetFilter (Instance property where the instance and it descendants get ignored by the Hit and Target properties)

You can easily move a part with these, for example:

-- LocalScript
loca Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Part = game.Workspace.ExamplePart

Mouse.Move:connect(function()
    local Position = Mouse.Hit.p
    Part.CFrame = CFrame.new(Position)
end)

Hope I helped!

~TDP

0
Thanks for the point in the right direction! OrcaTheFish 95 — 7y
Ad

Answer this question