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

How do i tween welded parts of a model?

Asked by
rexpex 45
6 years ago

I've been at this for an hour now, trying to tween these parts of a welded model. The model is a book, and im trying to make the script open the book, but since i have welds, its not able to do that at all. The tween works, but the welds are stopping it from being displayed.

local tweenserv = game:GetService("TweenService")
local grim = script.Parent
local lpage = grim:FindFirstChild("LPage")
local rpage = grim:FindFirstChild("RPage")
local rcover = grim:FindFirstChild("LCover")
local lcover = grim:FindFirstChild("RCover")
local spine = grim:FindFirstChild("Spine")

local debounce = false

local w1 = Instance.new("Weld")
local w2 = Instance.new("Weld")
local w3 = Instance.new("Weld")
local w4 = Instance.new("Weld")


w1.Part0 = spine
w1.Part1 = lcover
w1.C0 = w1.Part0.CFrame:inverse()*w1.Part1.CFrame
w1.Parent = w1.Part0

w2.Part0 = spine
w2.Part1 = rcover
w2.C0 = w2.Part0.CFrame:inverse()*w2.Part1.CFrame
w2.Parent = w2.Part0


w3.Part0 = lpage
w3.Part1 = lcover
w3.C0 = w3.Part0.CFrame:inverse()*w3.Part1.CFrame
w3.Parent = w3.Part0

w4.Part0 = rpage
w4.Part1 = rcover
w4.C0 = w4.Part0.CFrame:inverse()*w4.Part1.CFrame
w4.Parent = w4.Part0

function openbook()
  local tweenInfo = TweenInfo.new(

                    1,--duration

                    Enum.EasingStyle.Quint,--animation

                    Enum.EasingDirection.Out,--easing direction

                    5,--how many times it will repeat

                    true --determines whether it should return back

)
        if not debounce then 
            debounce = true


    local goal = {}
            goal.CFrame = CFrame.new(spine.Position) * CFrame.Angles(0,0,math.rad(5))*CFrame.new(0.706,0.05,0)
                local tween = tweenserv:Create(lpage, tweenInfo, goal)
                local tween2 = tweenserv:Create(lcover, tweenInfo, goal)

tween:Play()


    local goalreverse = {}
           goalreverse.CFrame = CFrame.new(spine.Position) * CFrame.Angles(0,math.rad(180),math.rad(5))*CFrame.new(0.706,0.05,0)
                local tween3 = tweenserv:Create(rpage, tweenInfo, goalreverse)
                local tween4 = tweenserv:Create(rcover, tweenInfo, goalreverse)

tween3:Play()

wait(3)
    debounce = false
end
end

openbook()
0
Don't put welds? Maybe if you don't put any welds BETWEEN the pages, make a row of invisible parts on the side then weld those to the pages and each other. ILikeTofuuJoe 1 — 6y
0
the pages are just a singular part, that would be really laggy if it was multiple rexpex 45 — 6y
0
2 pages btw, one on the left side of the book and one on the right rexpex 45 — 6y

Answer this question