Im working on a sort of dragable bar in roblox and depending on the position of the point returns a number but I cant seem to figure out how to get the number or even make it dragable.
this is my script so far.
--Objects//
local Parent = script.Parent
local MainParent = Parent.Parent
--Mouse
local Mouse = game.Players.LocalPlayer:GetMouse()
--Services
local RunService = game:GetService("RunService")
--Values//
local IsTouching = false
local IsDragging = false
local CurrentPosition = Parent.Position
local MaxNumber = 120
local MinNumber = 0
--Functions//
function Drag()
local X, Y = Mouse.X, MainParent.Position.Y
Parent.Position = UDim2.new(X, Y)
end
Mouse.Button1Down:Connect(function()
if IsTouching then
IsDragging = true
RunService:BindToRenderStep("DragObject", 1, Drag)
end
end)
Mouse.Button1Down:Connect(function()
if IsDragging then
IsDragging = false
RunService:UnbindFromRenderStep("DragObject")
end
end)
----------------------------------------------------------------
--Style Functions
Parent.MouseEnter:Connect(function()
Parent.BackgroundColor3 = Color3.fromRGB(27, 27, 27)
IsTouching = true
end)
Parent.MouseLeave:Connect(function()
Parent.BackgroundColor3 = Color3.fromRGB(46, 46, 46)
IsTouching = false
end)
If you need any more information on what I need help with then please ask.