I don't know how I would do this, I want it to be like when you grab a piece of dough in Work at a Pizza Place. When I click a part, I want it to follow my cursor until I click again. Any idea of how I could do this? This isn't a request, I genuinely don't know how to do this.
Unsure if this works outside of studio. Requires a ClickDetector in the part.
01 | local detector = script.Parent.ClickDetector |
02 | local following = false --Used to stop others from clicking |
03 | local leader = nil --Parent of mouse that clicked the detector |
04 | local stopFunc = nil |
05 |
06 | local runService = game:GetService( "RunService" ) --Recommend this over while loops |
07 |
08 | function followPlayer() |
09 | local mouse = leader:GetMouse() |
10 | local hit = mouse.Hit |
11 | local yAnchor = leader.Character:FindFirstChild( "HumanoidRootPart" ).Position.Y --Prevents dough from bouncing towards the screen |
12 |
13 | if hit then |
14 | script.Parent.Position = Vector 3. new(hit.p.X,yAnchor,hit.p.Z) |
15 | end |