function tweenJoint(o,G,m,O,W)spawn(function()local J=math.random(-1000000000.0,1000000000.0)local V=nil if not o:findFirstChild("\116\119\101\101\110\067\111\100\101")then V=Instance.new("\073\110\116\086\097\108\117\101")V.Name="\116\119\101\101\110\067\111\100\101"V.Value=J V.Parent=o else V=o.tweenCode V.Value=J end if W<=0 then if G then o.C0=G end if m then o.C1=m end else local r=1.5/W local k=o.C0 local S=o.C1 local C=0 while true do RS.RenderStepped:wait()local W=C+r C=W>90 and 90 or W if V.Value~=J then break end if G then o.C0=k:lerp(G,O(C))end if m then o.C1=S:lerp(m,O(C))end if C==90 then break end end end if V.Value==J then V:Destroy()end end)end function CreateWeld(o,G)local m=Instance.new("\087\101\108\100")m.Name="\076\101\103\087\101\108\100"m.Parent=char.LowerTorso m.Part0=char.LowerTorso m.Part1=o tweenJoint(m,nil,G,function(o)return math.sin(math.rad(o))end,.25)end
--[[
	tweenJoint Function Parameters:
	
	Object Joint - This has to be a weld with a C0 and C1 property
	
	CFrame newC0 - This is what the new C0 of the weld will be. You can put nil if you don't want to effect the C0
	
	CFrame newC1 - This is what the new C1 of the weld will be. You can put nil if you don't want to effect the C1
	
	function Alpha - This is an alpha function that takes an input parameter of a number between 0 and 90 and returns a number between 0 and 1.
		For example, function(X) return math.sin(math.rad(X)) end
		
	float Duration - This is how long the tweening takes to complete
--]]

function tweenJoint(Joint, newC0, newC1, Alpha, Duration)
	spawn(function()
		local newCode = math.random(-1e9, 1e9) --This creates a random code between -1000000000 and 1000000000
		local tweenIndicator = nil
		if not Joint:findFirstChild("tweenCode") then --If the joint isn't being tweened, then
			tweenIndicator = Instance.new("IntValue")
			tweenIndicator.Name = "tweenCode"
			tweenIndicator.Value = newCode
			tweenIndicator.Parent = Joint
		else
			tweenIndicator = Joint.tweenCode
			tweenIndicator.Value = newCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
		end
		if Duration <= 0 then --If the duration is less than or equal to 0 then there's no need for a tweening loop
			if newC0 then
				Joint.C0 = newC0
			end
			if newC1 then
				Joint.C1 = newC1
			end
		else
			local Increment = 1.5 / Duration --Calculate the increment here so it doesn't need to be calculated in the loop
			local startC0 = Joint.C0
			local startC1 = Joint.C1
			local X = 0
			while true do
				RS.RenderStepped:wait() --This makes the for loop step every 1/60th of a second
				local newX = X + Increment
				X = (newX > 90 and 90 or newX) --Makes sure the X never goes above 90
				if tweenIndicator.Value ~= newCode then
					break
				end --This makes sure that another tween wasn't called on the same joint
				if newC0 then
					Joint.C0 = startC0:lerp(newC0, Alpha(X))
				end
				if newC1 then
					Joint.C1 = startC1:lerp(newC1, Alpha(X))
				end
				if X == 90 then
					break
				end --If the tweening is done...
			end
		end
		if tweenIndicator.Value == newCode then --If this tween functions was the last one called on a joint then it will remove the code
			tweenIndicator:Destroy()
		end
	end)
end

function CreateWeld(Part, CF)
	local w = Instance.new("Weld")
	w.Name = "LegWeld"
	w.Parent = char.LowerTorso
	w.Part0 = char.LowerTorso
	w.Part1 = Part

	tweenJoint(w, nil, CF, function(X)
		return math.sin(math.rad(X))
	end, 0.25)
end
