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.
In that case I canāt help you, sorry.
I have never used a drag detector in the 6 years I have been in business. xd
I have now looked through all the Drag Detector information myself. I havenāt found anything related to changing the input.
I donāt think you can do that, or you need to write your own drag detector (mimicking a real drag detector) and then change the input.
Or maybe make it so that when you press E button, MouseButton1 is automatically pressed if you move the cursor over the object you want to drag.
Also, I found something similar to change input button, but it doesnāt work (screenshot below)
Has anyone figured out how to do this?