Changing A Number

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to change a number proportionaly(not sure if thats the right word) so basicaly i have power outa 50 i want to move it down to 25 but if the number is smaller it gets boosted more
  2. What is the issue? Include screenshots / videos if possible!
    im not sure what equation i would have to use
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    ive looked it up but not found anything (i might not be serching correctly tho)
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is swing script i need power to be shrunk as i said above
game.ReplicatedStorage.Swing.OnServerEvent:Connect(function(Plr, Type, Power)
	local AnimP = Power / 75
	if Type == "Right" then
		local anim = script.ForeHand
		local human = Plr.Character.Humanoid
		local animtrack = human:LoadAnimation(anim)
		animtrack:Play()
		animtrack:AdjustSpeed(AnimP)
	elseif Type == "Left" then
		local anim = script.BackHand
		local human = Plr.Character.Humanoid
		local animtrack = human:LoadAnimation(anim)
		animtrack:Play()
		animtrack:AdjustSpeed(AnimP)
	end
end)
2 Likes

So you want everytime you swing, you reduce the speed of your animation?

2 Likes

I have a power meter on the swing and sorry for not responding i was on a horse

I need to make it so the difference aint hardly moving and beyond human speeds

Looks like u need something exponential, u can use « ^ »

How would i do this? Im not verry far in school

idk but exponent works like that :

print(1^2) -- prints 1
print(2^2) -- prints 4
print(3^2) -- prints 9
print(4^2) -- prints 16
print(5^2) -- prints 25

I get thar but how would i get that to make smaller numbers gain a larger amt then bigger number??

So you want to make a power meter to charge up and speed up as it charges?

Ok so here is what i want i want it so you have a num outa 50 if the num 50 the num is 25 if the num is 0 it is 0 if the num is 10 its now 7.5 (dont have to be exactly based on that) if the num is 40 the new num is 20 basically the lower the number you devide it by 2 and add some factor im trying to make that work where the factor is based on how low it is so if its 50 the factor is 0

So do you want your power or charge level to be divided by a number so the charge level is lower for the animation?

In a way however i need it to be less of a difference rn its 0-50 and at like no hit its WAY to slow but at 50 its WAY to fast so i need a way to make that difference less

I can do that division just not this type of stuff

For :AdjustSpeed() function, the number you put in the parentheses is a multiplier. If you put 1 in, then the animation will stay the same speed. Putting in 0.5 will slow the speed of the animation in half. Putting in 2 will double the speed of the animation. You should probably have a limit on how slow or fast an animation can go.

Let’s say the power is 50. We can divide power by for example 100 to get 0.5. Now let’s say the power is really small like only 5. Now the speed multiplier is only 0.05. You should make a check like “if animPower < 0.25 then” and then set animPower to 0.25. You can do the same for the fast animation

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.