iBuzzes
(Ryan)
#1
Hi, I am trying to make a TextButton that you can press and move with the mouse on the X axis.
But it does not seem to work well because it is not positioned correctly.
local isPressing = false
task.spawn(function()
RunService.RenderStepped:Connect(function()
if isPressing then
local MouseLocation = UserInputService:GetMouseLocation()
SettingsFrame.SizeBar.TextButton.Position = UDim2.new(0, math.clamp(MouseLocation.X, 0, 285), SettingsFrame.SizeBar.TextButton.Position.Y.Scale, 0)
end
end)
end)
SettingsFrame.SizeBar.TextButton.MouseButton1Down:Connect(function()
isPressing = true
end)
SettingsFrame.SizeBar.TextButton.MouseButton1Up:Connect(function()
isPressing = false
end)
DarkPixlz
(darkpixlz)
#2
If it’s not positioned well, then it’s an issue with the Position line. Can you show us a photo/video of it when you move it?
iBuzzes
(Ryan)
#3
When I click on the TextButton this happens:
DarkPixlz
(darkpixlz)
#4
Check your math.clamp
amounts, also keep in mind that mouse.X/Y return in offset, not scale.
Pure_Bacn
(Pure_Bacn)
#5
local isPressing = false
RunService.RenderStepped:Connect(function()
if isPressing then
local MouseLocation = UserInputService:GetMouseLocation()
SettingsFrame.SizeBar.TextButton.Position = UDim2.new(0, math.clamp(0, game.Players.LocalPlayer:GetMouse().X, 0, 285), SettingsFrame.SizeBar.TextButton.Position.Y.Scale, 0)
end
end)
SettingsFrame.SizeBar.TextButton.MouseButton1Down:Connect(function()
isPressing = true
end)
SettingsFrame.SizeBar.TextButton.MouseButton1Up:Connect(function()
isPressing = false
end)
Try this. Idk… your code should be working…
Edit: Apparently clamp needs 3 numbers… my code is updated now
iBuzzes
(Ryan)
#6
Is there another function for it to return in scale? Or is there another way to do it so that it is in scale?
DarkPixlz
(darkpixlz)
#7
Not that I know of. You can view the mouse API here