Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Instance:Interpolate(numberproperty,numberstart,numberend,time)
- -- Example at bottom
- local oldinstance = Instance.new;
- local Instance = {};
- local metas = {
- __index = function(s,i)
- return s._u[i];
- end,
- __newindex = function(s,i,v)
- s._u[i]=v;
- end
- }
- function interpolate(s,prop,startValue,targetValue,d)
- if type(targetValue) == "number" then
- local object = s._u;
- local time, duration = tick(), d;
- local halfPi = math.pi/2;
- local difValue = targetValue - startValue;
- repeat
- local i = math.sin(((tick() - time) / duration) * (halfPi));
- object[prop] = startValue + ((difValue) * i)
- wait();
- until
- tick() - time >= duration
- object[prop] = targetValue;
- end
- end
- function find(obj,str)
- local a,b = pcall(function() print(obj[str]) end);
- return a;
- end
- function destroy(s)
- s = null;
- s._U:Destroy();
- end
- function get(obj)
- if type(obj) == 'userdata' then
- if find(obj,'Parent') and not find(obj,'_u') then
- local array = {_u=obj,Interpolate=interpolate,Destroy=destroy};
- array.u = obj;
- array.Interpolate = interpolate;
- setmetatable(array,metas);
- return array;
- else
- error(".",0);
- end
- else
- error("..");
- end
- end
- Instance.new = function(str,par)
- local array = {
- Destroy=destroy,_u=oldinstance(str,par),Interpolate = coroutine.wrap(interpolate)
- };
- setmetatable(array,metas);
- return array;
- end
- p = Instance.new("Part",Workspace);
- p.Name = "Hi";
- wait(4);
- p:Interpolate("Transparency",0,1,2);
- BasePlate = get(Workspace.BasePlate)
- BasePlate:Interpolate("Reflectance",0,2,5);
Add Comment
Please, Sign In to add comment