How would I be able to assign a key to activate a drag detector? In my case, I want the player to be able to drag stuff with E, but NOT with left click. I already have the raycasting and code that is needed to detect what the player wants to drag, but I am not sure how I can active the drag detector.
U mean this?
local UIS = game:GetService("UserInputService")
local Dragging = false
UIS.InputBegan:Connect(function(i,ini)
if ini then return end
if i.KeyCode == Enum.KeyCode.E then
Dragging = true
print("_Current State: "..Dragging)
-- Make here start dragging
end
end)
UIS.InputEnded:Connect(function(i,ini)
if ini then return end
if i.KeyCode == Enum.KeyCode.E then
Dragging = false
print("_Current State: "..Dragging)
-- Make here stop dragging
end
end)
the ā-- Make here start draggingā part is where the problem is. I canāt find any function or property in a Drag Detector that I can use or change to force the player to drag.
uhhh
u mean it?
![]()
yes, i mean that, a drag detector.
Well, then, Iāll put it this way.
Drag detector is used only for mouse tracking.
In your case, if you want to make Drag Detector to be, it will only be there
(for looks)
You need to write a code that when you hover the mouse over an object, that object will be dragged when you click on the E button.
for example, in local script
CurrentItem = nil
(when hovering over an item) CurrentItem will be equal to the Item that the player hovered the mouse over, if the player does not hover over an item, CurrentItem will also be equal to nil.
In the script you should make a function when pressing the E button, so that the condition:
( if mouse.Target.Parent.Name == CurrentItem then )
⦠ur drag func
I dont quite get it?
The drag detector actually drags the item with the mouse without further code. My game is first person so in this case you move your camera to drag the object with you. I want the drag detector get activated when you press a key. Iāve already coded the inputs, and I am using raycasts to detect what the player is trying to drag. The last missing step that I canāt quite get is activating the drag detector, this means I have no drag function because the Drag Detector is already handling that.
Has anyone figured out how to do this?
Yes, but this also affects GuiButtons and Tools.
For example:
game:GetService("ContextActionService"):BindActivate(Enum.UserInputType.Keyboard, Enum.KeyCode.R)
In case anyone finds this topic because it came up first when i searched on google:
At least when dragstyle is set to RotateAxis, you can manually set the DragFrame CFrame to rotate it to what you need. Then you can change it when you detect player input. I havenāt tested it with other dragstyles, but this worked for me!
I feel like DragDetectors would be way more useful if they were a bit more decoupled from input. I have 2 applications where DragDetectors would be literally perfect, but I canāt use them because they are so tightly coupled to input and hard to interface with programmatically.