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

Model won't slide smoothly?

Asked by 6 years ago

Hello, I want to slide a model, but It isn't very working. While the parts are smoothly sliding, The model isn't (parts use a very different script) Can someone help?It goes to the end position at once.

local part = workspace.TestModel.Partlol
local model = workspace.TestModel
workspace.TestModel.PrimaryPart = workspace.TestModel.Partlol


function ModelMove()
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
    model:SetPrimaryPartCFrame(CFrame.new(4.0342, 0, 0))
    wait(0.1)
end

workspace.Boat.Body.Button.ClickDetector.MouseClick:connect(ModelMove())

And the script of the sliding parts is:

local Part = workspace.Sea7 -- this is the Part we will move
local newPos = Part.Position + Vector3.new(403.42,0,0) -- the position the Part will go to
local Time = 10 -- the time that the script will take to move the part
local Increment = 0.05 -- the Part will move 0.5 studs each time it moves
local Debounce = false

local Diff = newPos - Part.Position -- the difference between the two positions
local Mag = Diff.magnitude -- the distance between the two parts
local Direction = CFrame.new(Part.Position, newPos).lookVector

function MovePart() -- function to move the Part
    if Debounce then return end -- end the function if debounce is true
    Debounce = true -- make Debounce true so the function can't run
    for n = 0, Mag, Increment do
        Part.CFrame = Part.CFrame + (Direction * Increment)
        wait( (Time/Mag) * Increment )
    end
    Debounce = false -- set Debounce to false so the function can run again
end

workspace.Boat.Body.Button.ClickDetector.MouseClick:connect(MovePart)

0
why do you set the same postition eacht time ((4.0342,0,0))? abnotaddable 920 — 6y

Answer this question