Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm making a floating TWEEN when I touch the part, but the TWEEN isn't quite working. Why?

Asked by 3 years ago

So basically I wrote a script where when I would touch it, it would weld to my hrp (HumanoidRootPart) and have a position of 10 studs high to look like it was above my head floating. Although, It doesn't look too good so I decided I was going to add a floating part tween to the part. (I did tween the weld because tweening a welded part doesn't work) The tween plays but in the wrong direction. Also even when I change the position. It does the same tween, and it's like the position set hasn't even changed for the computer. Like regularly Y 3 would go up Y -3 would go down. That's not the case in this, not only does it not change the down or up. It doesn't EVEN go down or up it goes side to side with a slight curve even though I am using UpVector. Here is the script:

local weld = Instance.new("Weld")
local wp = script.Parent
local twServ = game:GetService("TweenService")
local twInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true, 0)
local debounce = true

function Stepped(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local hrp = hit.Parent.HumanoidRootPart
        local tw = twServ:Create(weld, twInfo, {C0 = weld.C0 + weld.C0.UpVector * 3})
        if debounce == true then
            debounce = false
            wp.Anchored = false
            wp.CFrame = hrp.CFrame + Vector3.new(0,10,0)
            weld.Part0 = hrp
            weld.Part1 = wp
            weld.C0 = hrp.CFrame:Inverse()
            weld.C1 = wp.CFrame:Inverse()
            weld.Parent = wp    
            tw:Play()

            wait(2)
        end
    end
end

wp.Touched:Connect(Stepped)

here is main line in the script that I'm talking about:

local tw = twServ:Create(weld, twInfo, {C0 = weld.C0 + weld.C0.UpVector * 3})

also here is a video of what the tween looks like https://i.gyazo.com/df29cef377cce047006ecdc0172c10a2.mp4

Answer this question