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

Tweening a mesh does not make it move?

Asked by 2 years ago

In a previous post I had an issue where GetPrimaryPartCFrame is not a valid member of MeshPart, so I revamped it, yet instead of an error i get no errors. Can somebody please tell me why?

local RStorage = game:GetService("ReplicatedStorage")

local SummonBert = RStorage:WaitForChild("SummonBert",math.huge)

local bert = RStorage:FindFirstChild("bigcat")

local tweenService = game:GetService("TweenService")



local Info = TweenInfo.new(

    10  
)
local goal = {

    Position = Vector3.new(-36, 596, -15)

}

local MoveBert = tweenService:Create(bert, Info, goal)



MoveBert.Completed:connect(function()
    for i,v in pairs(game:GetService("Players"):GetPlayers()) do
        wait(3)
        v:Kick("Nothing remains in this world")
    end
end)


SummonBert.OnServerEvent:Connect(function(player)
    bert:Clone().Parent = workspace
    print("Bert has entered workspace")
    wait(3)
    MoveBert:Play()

    print("OUR LORD AND SAVIOR, BERT HAS BEEN SUMMONED, ALL HAIL BERT")
end)

1 answer

Log in to vote
1
Answered by 2 years ago

That's because the variable bert is referring to the object inside ReplicatedStorage. When you clone the object, it still will refer to the original object.

Instead, create the Tween after the object has been cloned, and refer to that instead.

local RStorage = game:GetService("ReplicatedStorage")

local SummonBert = RStorage:WaitForChild("SummonBert",math.huge)

local bert = RStorage:FindFirstChild("bigcat")

local tweenService = game:GetService("TweenService")



local Info = TweenInfo.new(

    10  
)

local goal = {

    Position = Vector3.new(-36, 596, -15)

}

local MoveBert = tweenService:Create(bert, Info, goal)



MoveBert.Completed:connect(function()
    for i,v in pairs(game:GetService("Players"):GetPlayers()) do
        wait(3)
        v:Kick("Nothing remains in this world")
    end
end)


SummonBert.OnServerEvent:Connect(function(player)
    local bertClone = bert:Clone()
    bertClone.Parent = workspace
    local MoveBert = tweenService:Create(bertClone, Info, goal)
    print("Bert has entered workspace")
    wait(3)
    MoveBert:Play()

    print("OUR LORD AND SAVIOR, BERT HAS BEEN SUMMONED, ALL HAIL BERT")
end)
Ad

Answer this question