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

how do I use the dragger instance and how can I utilize it in my script?

Asked by 4 years ago
local tool = script.Parent.Parent
local char = tool.Parent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()




local dragger = Instance.new("Dragger")

dragger.MouseDown:Connect(function()
    local hit = mouse.Hit
    local target = mouse.Target
    --moving "mouse.target" ???--
end)

I have a simple localscript for testing the dragger instance but im stuck.

how do I use it? how do I "drag" mouse.Target?

0
You mean to move the part with the mouse, right? Eternalove_fan32 188 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

https://robloxplosion.blogspot.com/2017/03/scripting-how-to-script-moveable.html --Credits to this guy

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local down
local mtarget

function clickObj()
if mouse.Target ~= nil then
mtarget = mouse.Target
print(mtarget)
down = true
mouse.TargetFilter = mtarget
print(mouse.TargetFilter)
end
end
mouse.Button1Down:connect(clickObj)

function mouseMove()
if down and mtarget then
local posX,posY,posZ = mouse.hit.X, mouse.hit.Y, mouse.hit.Z
mtarget.Position = Vector3.new(posX,posY,posZ)

end
end
mouse.Move:connect(mouseMove)

function mouseDown()
down = false
mouse.TargetFilter = nil

end
mouse.Button1Up:connect(mouseDown)
Ad

Answer this question