of     1   

DeepBlueNoSpace
#182248903Saturday, January 23, 2016 7:43 PM GMT

Started off well, then got horrifically confused. I'm making a custom lerp as I want to tween at speeds not possible with a standard :tween My current issue revolves around my maths. This: function lerpnum(val, val2, amount) return ((1-amount)*val) + (amount*val2) end function _M.lerp(value1, value2, amount) return UDim2.new(lerpnum(value1.X.Scale, value2.X.Scale, amount), lerpnum(value1.X.Offset, value2.X.Offset, amount), lerpnum(value1.Y.Scale, value2.Y.Scale, amount), lerpnum(value1.Y.Offset, value2.Y.Offset, amount)) end Called with this: m = require(game.ServerScriptService.ModuleScript) local val1 = UDim2.new(1,1,1,1) local val2 = UDim2.new(2,2,2,2) print(m.lerp(val1, val2, .5)) Outputs this: {1.5, 1}, {1.5, 1} An explation is just as helpful as the solution for this one. Thanks
KAAK82
#182249210Saturday, January 23, 2016 7:47 PM GMT

Me and my friend were also thinking about this... we also got a bit stuck, but we were on the right Path... local function lerp(n0, n1, num) local d = math.abs(n0 - n1) local n = d * num return n0 + n end Try this :P
KAAK82
#182249357Saturday, January 23, 2016 7:49 PM GMT

Actually wait there local d = n1 - n0 there
fishguy100
#182249944Saturday, January 23, 2016 7:56 PM GMT

function lerpnum(val,val2,amount) return val + (val2 - val1) * amount end
KAAK82
#182250110Saturday, January 23, 2016 7:59 PM GMT

That's just a shortened version of what I gave :P
DeepBlueNoSpace
#182254511Saturday, January 23, 2016 8:57 PM GMT

Thanks
KAAK82
#182255508Saturday, January 23, 2016 9:11 PM GMT

Works? Np ;)
cody123454321
#182255809Saturday, January 23, 2016 9:15 PM GMT

function lerp(a, b, c) return (1-c)*a+(b*c) end local start = 0 local end = 10 local alpha = 0.5 print(lerp(start, end, alpha)) --> 5 alpha = 0.25 print(lerp(start, end, alpha)) --> 2.5
DeepBlueNoSpace
#182258373Saturday, January 23, 2016 9:52 PM GMT

The lerp works, but the rest of the script doesn't. This causes the decal to fly off the screen, any idea why? mouse.Move:connect(function() if mouse.Target and debounce then debounce = false while mouse.Target and mouse.Target.Name == "Interact" and not small do small = true for i = 10, 20, .5 do if mouse.Target and mouse.Target.Name == "Interact" then local newnum = -5 - ((i - 10) / 2) local newpos = m.lerp(decal.Position, UDim2.new(0, newnum, 0, newnum), i) decal.Position = newpos print(newpos) wait(.1) end end wait() end --small = false --[[while mouse.Target and mouse.Target.Name ~= "Interact" and decal.Size.X ~= 10 do for i = decal.Size.X.Offset, 10, -1 do if mouse.Target and mouse.Target.Name ~= "Interact" then local newnum = 0 decal:TweenSize(UDim2.new(0, i, 0, i)) wait(.05) end end wait() -- Just a saftey net end]] end debounce = true end)
C_Sharper
#182258596Saturday, January 23, 2016 9:55 PM GMT

Are you making a lerp that works with Gui elements?
DeepBlueNoSpace
#182259156Saturday, January 23, 2016 10:04 PM GMT

Yup
C_Sharper
#182259236Saturday, January 23, 2016 10:05 PM GMT

Sounds really useful. Are you planning on making it free for the public?
DeepBlueNoSpace
#182259443Saturday, January 23, 2016 10:08 PM GMT

I hadn't considered it, but given I could use it as a publicity stunt, maybe. The lerp work, btw. It's just implementing it is what I'm struggling with. If you want the code, it's here: function lerpnum(val,val2,amount) return val + (val2 - val) * amount end function _M.lerp(value1, value2, amount) return UDim2.new(lerpnum(value1.X.Scale, value2.X.Scale, amount), lerpnum(value1.X.Offset, value2.X.Offset, amount), lerpnum(value1.Y.Scale, value2.Y.Scale, amount), lerpnum(value1.Y.Offset, value2.Y.Offset, amount)) end It's uses are limited to high frequency tweening though
C_Sharper
#182259601Saturday, January 23, 2016 10:11 PM GMT

Cool! Good luck with it.
KAAK82
#182259674Saturday, January 23, 2016 10:12 PM GMT

What u trying to do?
DeepBlueNoSpace
#182260177Saturday, January 23, 2016 10:19 PM GMT

When a player hovers his mouse over a part called interact, decal (mouse is made invisible as it is less customisable), is swollen. I would normally achieve this with tween, but if he moves off it whilst it's still expanding, with tween it'll finish the expansion then shrink. I want it to automatically shrink.
ray_revenge
#182260249Saturday, January 23, 2016 10:21 PM GMT

DeepBlueNoSpace
#182260313Saturday, January 23, 2016 10:22 PM GMT

If you override it with another tween, it screws up
DeepBlueNoSpace
#182261973Saturday, January 23, 2016 10:43 PM GMT

It doesn't ruin the effect to do it like that though. Mhmmm...
KAAK82
#182266630Saturday, January 23, 2016 11:54 PM GMT

Seems weird :/ I half don't get it and half don't understand the Code :/

    of     1