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

How do I make a Draggable Brick?

Asked by 5 years ago
Edited 5 years ago

I've looked online for this and found some things, but not what I wanted. I found scripts to make a brick draggable, but u could also drag everything else. I've been scripting for over a year but im still not advanced enough to do this. If you could explain it on simple terms or show me how I would do this please help lol (Also I dont want a tool to have to be used)

0
if you looked for something could you post it? User#19524 175 — 5y
0
I only found https://www.youtube.com/watch?v=HW8K6FblwvI and I found a forum post earlier on how to do it with a tool barrettr500 53 — 5y

1 answer

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

heres the edited answer; u may notice that it was only a slight edit

local mouse = game.Players.LocalPlayer:GetMouse()
local mousetarget
local grabbing = false

mouse.Button1Down:connect(function()
    mousetarget = mouse.Target
    local purchase = mousetarget:FindFirstChild("Purchase")

    if purchase ~= nil and purchase.Value == true then
        mouse.TargetFilter = mousetarget
        grabbing = true
    end
end)

mouse.Move:connect(function()
    if grabbing == true then
        mousetarget.Position = mouse.Hit.p
    end
end)

mouse.Button1Up:connect(function()
    grabbing = false
    mouse.TargetFilter = nil
end)
0
it uses the mouse targefilter tho if thats ok TheluaBanana 946 — 5y
0
the targetfilter should be fine theking48989987 2147 — 5y
0
also, wouldn't a renderstepped event also work? theking48989987 2147 — 5y
0
and there is a couple of minor convention errors, for one, mouse.Hit.p should now be mouse.Hit.Position and connect was deprecated in favor of Connect theking48989987 2147 — 5y
View all comments (12 more)
0
Where would I put the script? And do I need to make any strings of anything? barrettr500 53 — 5y
0
oof TheluaBanana 946 — 5y
0
lol barrettr500 53 — 5y
0
nothing complicated starterpack should be fine TheluaBanana 946 — 5y
0
Its not letting me drag stuff, does it need to be name something? click detector? I made it a local script in the starterpack barrettr500 53 — 5y
0
well ye u gotta define the mousetarget of the scriptn to the part u want sry for tha late reply btw had t5o run an errand TheluaBanana 946 — 5y
0
oof thats a lot of typos TheluaBanana 946 — 5y
0
Omg thx so much it works barrettr500 53 — 5y
0
np TheluaBanana 946 — 5y
0
I tampered with the script but couldn't get it to work, how would I make every part that has a bool value in it named Purchase set to true be draggable? lol sorry for bugging u so much barrettr500 53 — 5y
0
oof i thought i was done so i didnt check sry TheluaBanana 946 — 5y
0
ok ill edit the above existing one TheluaBanana 946 — 5y
Ad

Answer this question