I’m trying to me a settings ui for my game and i’m using UI Drag detecters for the sliders following a tutorial I made the code to make a percentage between 0 and 1 but its not working right can someone please help?
Code:
local Frame = script.Parent
local ScrollFrame = Frame:WaitForChild("ScrollFrame")
local Music = ScrollFrame:WaitForChild("Music")
local Buttion = Music:WaitForChild("Bar"):WaitForChild("Buttion")
local Num = -22
local num = Buttion.Position.X.Offset/453
Buttion:GetPropertyChangedSignal("Position"):Connect(function()
print(num)
end)
Video:
the percentage is supposed to display on the output buts its displaying a weird number
your variable is defined at the top, its not defined in the function, so it’ll always stay the same
local Frame = script.Parent
local ScrollFrame = Frame:WaitForChild("ScrollFrame")
local Music = ScrollFrame:WaitForChild("Music")
local Button = Music:WaitForChild("Bar"):WaitForChild("Buttion")
Button:GetPropertyChangedSignal("Position"):Connect(function()
local num = Button.Position.X.Offset / 453
print(num)
end)
local Frame = script.Parent
local ScrollFrame = Frame:WaitForChild("ScrollFrame")
local Music = ScrollFrame:WaitForChild("Music")
local Button = Music:WaitForChild("Bar"):WaitForChild("Buttion")
Button:GetPropertyChangedSignal("Position"):Connect(function()
local num = (453 - Button.Position.X.Offset) / 453
print(num)
end)