Heyo Guys,
I’ve been using the amazing Simple Module For Creating Draggable GUI Elements.
But I’m stumped with the issue, how would I make this work from the server?
As I’m creating a Gui with Instance.new’s and I want it to be draggable.
Draggle Property doesn’t exist anymore.
Thanks,
Sasial.
I believe you’re trying to do something like this:
local frame = Instance.new("Frame")
local frameDrag = DraggableObject.new(frame)
If you are attempting to do this in a server script it will not work. It can only be used on the client. You could create the GUI with a server script then allow the client to set up all the dragging.
This can be done by placing the GUI somewhere from the server where the client can see it, then the client can set up dragging for all the relevant frames.
You could use a RemoteEvent and fire it to the client with the argument being the Frame you want to be able to be dragged. This code should work for your needs:
Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Name = "DragEvent"
RemoteEvent.Parent = ReplicatedStorage
function createGui(player) -- Function to create the gui.
-- do your frame creation code here
RemoteEvent:FireClient(player, Frame) -- Frame
end
Client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DragEvent = ReplicatedStorage:WaitForChild("DragEvent")
local DraggableObject = require(pathtodraggableobject)
function Event(Frame)
local FrameDrag = DraggableObject.new(Frame)
FrameDrag:Enable()
end
DragEvent.OnClientEvent:Connect(Event)
Feel free to modify this for your needs.
Edit: Forgot to call Enable on FrameDrag.
Hello, you can still use Draggable function in localscript. I use it in localscript Frame and works. You don’t need to philosophy about it. Here is my script:
script.Parent.Active = true
script.Parent.Draggable = true
I hope it helps.
The draggable
property is deprecated and it’s not recommended to use it. It can be quite buggy at times, for example if you drag something a bit to fast it will simply freeze and not move anymore. More about this can be read in the replies here:
Thanks so much! Really appriciate all of your answers.