I have a scripted tool that lets me create parts then move them as accordingly to my desire but I want to be able to allow dragging like real functional building tools. Let's say I have a part which is one of the spheres (that represents forward), how would I make it that if I wanted to drag it, it would keep moving it?
Here is a basic idea of my script, it should be simple to understand:
01 | local part = Instance.new( "Part" ) |
02 | part.Position = Vector 3. new( 0 , 5 , 0 ) |
03 | part.Size = Vector 3. new( 2 , 2 , 2 ) |
04 | part.Parent = workspace |
05 | local sphere = Instance.new( "Part" ) |
06 | sphere.Name = "LookVectorSphere" |
07 | sphere.Position = workspace |
08 |
09 | local increment = 1 |
10 |
11 | local function movePartForward() |
12 | part.Position = part.Position + (part.CFrame.LookVector* 1 ) |
13 | sphere.Position = sphere.Position + (part.CFrame.LookVector* 1 ) |
14 | end |
This is just an example to make it clear and easy of what I'm asking so I will only be asking for that one sphere example I gave.
Fixed script from user bostaffmanbulgaria1 Who he stole from a guy that didn't know anything about scripting. Go ahead and use this!
01 | -- The following script allows you to move the part, but not Up in the Y axis because I'm too stupid for this one... |
02 |
03 | ---------------- |
04 | -- LocalScript |
05 | ---------------- |
06 | local PlayerMouse = game.Players.LocalPlayer:GetMouse() |
07 | local DraggablePart = game.Workspace.DraggablePart |
08 | local PartPositionEvent = script.PartPositionEvent |
09 | local Draggable = false |
10 | local Target = nil |
11 |
12 |
13 | PlayerMouse.Button 1 Down:Connect( function () |
14 | Draggable = true |
15 | repeat |
01 | -- The following script allows you to move the part, but not Up in the Y axis because I'm too stupid for this one... |
02 |
03 | ---------------- |
04 | -- LocalScript |
05 | ---------------- |
06 | local PlayerMouse = game.Players.LocalPlayer:GetMouse() |
07 | local DraggablePart = game.Workspace.DraggablePart |
08 | local PartPositionEvent = script.PartPositionEvent |
09 | local Draggable = false |
10 | local Target = nil |
11 |
12 |
13 | PlayerMouse.Button 1 Down:Connect( function () |
14 | Draggable = true |
15 | repeat |