Rthro Scaling Gui

Hello! Does anyone have any tips or ideas on where to start with making a scaling knob for Rthro in a custom character gui? I’ve been looking around for other threads or ideas on it. And i’m thinking i’d like to use humanoid description. Ik how to use it and all that, I’m just looking for advice on the knobs themselves. :slight_smile: Thx!

1 Like

Unless you need knobs for the style of your game, I think that using sliders would be better. Generally speaking, they’re easier to comprehend and move than a knob would be, and it would be easier to implement. This topic has some replies that show how a slider can be used for input. In addition, a simple search like “slider gui” yielded some good results for me.

If you’d like to stick with knobs, then that’s out of my expertise currently. You’ll likely have to work with some more complex math.

Thats what i meant XD I couldnt find the words lol. sliders

Oh, haha :smile:. Try and see if you can implement them, and if not we can help.

Thankyou! I’ll let you know… i’m sure i can get it working. I suppose i may just need help with when i get to figuring out all the percentage math for it…

@Crazycat4360 So, now i’m having an issue… the player is in fact sorta scaling but its strange… they are either really skinny, or of max width… i am sending the x position factor to the server where i do the scaling… and it says when its says that “the humanoid has no humanoid root part” in the errors. I’m guessing its because its sending through a lot of really long decimals. In the server it uses apply description. And that part seems to be working… but, its being strange

local Dragging

Slider.MouseButton1Down:connect(function()
	Dragging = true
end)

Slider.MouseButton1Up:connect(function()
	Dragging = false
end)

game:GetService("UserInputService").InputChanged:connect(function(InputObject, GameProcessedEvent)
	if ((not GameProcessedEvent) and Dragging) then
		if (InputObject.UserInputType == Enum.UserInputType.MouseMovement) then
			Slider.Position = UDim2.new(0, (InputObject.Position.X - Container.AbsolutePosition.X), -0.276, 0)
			if (Slider.AbsolutePosition.X < Container.AbsolutePosition.X) then
				Slider.Position = UDim2.new(0, 0, -0.276, 0)
			elseif (Slider.AbsolutePosition.X > (Container.AbsolutePosition.X + Container.AbsoluteSize.X)) then
				Slider.Position = UDim2.new(1, -Slider.AbsoluteSize.X, -0.276, 0)
			end
			self.Services.Character_Appearance_Service.Scale_Change:Fire(Container.Name, Slider.Position.X.Scale)
		end
	end
end)

Oh… and i’m using the aero game framework so thats why that event looks strange… but it works :slight_smile:

Try moving your event to the mouse up function rather than where it is now. Firing the event every time the mouse moves isn’t necessary or good for performance.

Moving on to the scaling error, you’ll have to post the server’s code relevant to scaling the character.

Ok thankyou, that aside, the line where it moves the slider, i’d like it to move by way of the scale and not the offset. Right now its on the offset. I figured out that that is my current issue, because i’m sending the sliders x.scale position through the event, and therefore its either idexing 0 or 1… so i need that chunk of script to work by way of the scale. That and i’m not even sure if using the the x.scale position as the value of the scale being passed is the right way of doing it. I’m not entire sure how the regular roblox scaling is based on math wise, because if i put a the widthscale for instance at 0, its just a tiny little super thin person that is practically invisible, and i don’t want that. Any thoughts?

Yes, you should use the scale property; it’ll be a value between 0 and 1 if you’ve setup your UI correctly. Then on the server, you could set up a formula such as (scaleValue + 0.5) ^ 2. Assuming you then clamp the scale value between 0 and 1, the output from the formula will always be between 0.25 and 2.25; you can use this value to set the player’s scale.

Feel free to modify the above formula, it’s just an example.

1 Like

Okay cool, Then the only factor i have left is manipulating the code i posted above into sliding on the scale factor and not the offset factor… i’m not as familiar with the gui math here, i’ve tried moving the Slider.Position = UDim2.new(0, (InputObject.Position.X - Container.AbsolutePosition.X), -0.276, 0) to Slider.Position = UDim2.new((InputObject.Position.X - Container.Position.X.Scale), 0, -0.276, 0) because i know that the abosolutepostition wont work on the scale… but that did nothing :confused:

and if i could even increment the way the sliders position works in accordance with the formula you just gave me that would be even better

Alright, I think I finally got it working. Here’s the updated code:

local UserInputService = game:GetService("UserInputService")
local Container = script.Parent.Parent
local Slider = script.Parent
local Dragging
local LastPosition

local function Send()
	if Slider.Position.X.Offset ~= LastPosition then
		-- Fire your event here with Slider.Position.X.Offset / Container.AbsoluteSize.X to get a number between 0 and 1.
		LastPosition = Slider.Position.X.Offset
	end
end

Slider.MouseButton1Down:Connect(function()
	Dragging = true
end)

Slider.MouseButton1Up:Connect(function()
	Dragging = false
	Send()
end)

UserInputService.InputEnded:Connect(function(InputObject, GameProcessedEvent) -- This stop the slider from being moved when the mouse button is
	-- up but the event isn't registered; when it's released and the mouse in not on top of the slider.
	if ((not GameProcessedEvent) and Dragging) then
		if (InputObject.UserInputType == Enum.UserInputType.MouseButton1) then
			Dragging = false
			Send()
		end
	end
end)

UserInputService.InputChanged:Connect(function(InputObject, GameProcessedEvent)
	if ((not GameProcessedEvent) and Dragging) then
		if (InputObject.UserInputType == Enum.UserInputType.MouseMovement) then
			Slider.Position = UDim2.new(0, (InputObject.Position.X - Container.AbsolutePosition.X), 0, 0)
			if (Slider.AbsolutePosition.X < Container.AbsolutePosition.X) then
				Slider.Position = UDim2.new(0, Slider.AbsoluteSize.X / 2, 0, 0)
			elseif (Slider.AbsolutePosition.X > (Container.AbsolutePosition.X + Container.AbsoluteSize.X - Slider.AbsoluteSize.X)) then
				Slider.Position = UDim2.new(0, Container.AbsoluteSize.X - (Slider.AbsoluteSize.X / 2), 0, 0)
			end
		end
	end
end)

Here’s the place file I tested it with: Slider.rbxl (21.1 KB)

1 Like

Thankyou! You are the best! :slight_smile: This works great!

And just one more question for you: Do you know how roblox deals with the percentages in the Avatar menu scaling options? So that you cant make them too thin or too short and all that? :slight_smile:

Roblox likely clamps the value between 70% and 100% (0.7 and 1). Here’s a formula that I found online:
((Input - InputLow) / (InputHigh - InputLow)) * (OutputHigh - OutputLow) + OutputLow
Using this on our result from Slider.Position.X.Offset / Container.AbsoluteSize.X will give us a properly converted number. For example, 0.5 on the slider will give us 0.85 as a result.

-- We can substitute our min and max scale values
((Input - 0) / (1 - 0)) * (1 - 0.7) + 0.7
-- Simplifying that gives us
Input * 0.3 + 0.7
-- Putting this in your event would look like this
local convertedNum = (Slider.Position.X.Offset / Container.AbsoluteSize.X) * 0.3 + 0.7
-- Event:Fire(convertedNum) -- Would be 0.85 from the example above

It took me awhile to figure this out. Sorry if it doesn’t make much sense, I’m semi-confused too lol.

Edit: Removed / 1 from the formula since dividing by 1 does nothing :sweat_smile:

wow, you are da bomb… I can’t thank you enough! Seriously dude. And i learned something. Thx. :slight_smile:

You get to be my official hero for today! And you get 4 star stickers, one more and you get to go to chucky cheese :stuck_out_tongue: :laughing:

But seriously dude, 5 stars to you, thx!
@Crazycat4360

2 Likes