#How would i make a moving platform with localtween?

1 messages · Page 1 of 1 (latest)

lament quartz
#

I'm trying to implement localtween with this script but i'm unsure on how to do it.

local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local part = script.Parent

local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, -1, true)

local tween = TweenService:Create(part, tweenInfo, {
    CFrame = part.CFrame * CFrame.new(0, 0, -10)
})

tween:Play()

local lastPosition = part.Position

RunService.Stepped:Connect(function(_, deltaTime)
    local currentPosition = part.Position
    local deltaPosition = currentPosition - lastPosition
    
    local velocity = deltaPosition / deltaTime
    
    part.AssemblyLinearVelocity = velocity
    
    lastPosition = currentPosition
end)

^ Server script

#

I've tried making a "LocalVelocity" script but it doesn't really do anything

LOCALVELOCITY ->

local RunService = game:GetService("RunService")

local parts = {}

for _, v in pairs(game.Workspace:GetDescendants()) do
    if v:GetAttribute("CanMove") == true and not table.find(parts, v) then
        table.insert(parts, v)
    end
end

game.Workspace.Changed:Connect(function()
    for _, v in pairs(game.Workspace:GetDescendants()) do
        if v:GetAttribute("CanMove") == true and not table.find(parts, v) then
            table.insert(parts, v)
        end
    end
end)

for _, part in pairs(parts) do
    local lastPosition = part.Position

    RunService.Stepped:Connect(function(_, deltaTime)
        local currentPosition = part.Position
        local deltaPosition = currentPosition - lastPosition

        local velocity = deltaPosition / deltaTime

        part.AssemblyLinearVelocity = velocity

        lastPosition = currentPosition
    end)
end

PART SERVER SCRIPT ->

wait(10)

local TweenService = require(game.ServerStorage.LocalTween)
local RunService = game:GetService("RunService")

local part = script.Parent

local tweenInfo = {2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, -1, true}

local tween = TweenService.Tween(part, tweenInfo, {
    CFrame = part.CFrame * CFrame.new(0, 0, -10)
})
spice ocean
#

What is localtween

#

How is it different than tween

median sorrel
#

bro what

spice ocean
#

Just try this ig, Idk what u trying to do

local part = workspace.Part
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, -1, true)
local tween = tweenService:Create(part, tweenInfo, {Position = part.Position + Vector3.new(0,0,10)})

tween:Play()```