Hello! i took the mouse dragging object script from here:
i can’t quite find the place that says if mouse down then do this do that, i want to modify it so that i can do it when i press e instead, can you please tell me where the mouse1down thing is so i can change it to key bind?
local player = game.Players.LocalPlayer --the local player
local mouse = player:GetMouse() --his mouse
local target --this variable will hold the part that's being currently dragged
local down --this determines wether we are pressing or not
mouse.Button1Down:connect(function()
if mouse.Target ~= nil and mouse.Target.Locked == false then --checking if the mouse is actually hovering over an object, the locked property isn't really important
target = mouse.Target --the target is set
mouse.TargetFilter = target --preventing issues
down = true
end
end)
mouse.Move:Connect(function()
if down == true and target ~= nil then --this event will be always firing, but we wanna change the target's position only when clicking, that's why we check if down is true
target.Position = mouse.Hit.Position --the part that sets the position!
end
end)
mouse.Button1Up:connect(function()
down = false --and remember that after ending the holding, you wanna reset some properties
mouse.TargetFilter = nil
target = nil
end)
It’s on the 6th line, and Button1Up is on the 5th to last line.