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

How do you make a moving/sliding brick?

Asked by 7 years ago
Edited 7 years ago

Okay. The one on I use,

local Part = Workspace.Part
local newPos = Part.Position + Vector3.new(0,5,0)
local Time = 10
local Increment = 0.5
local Debounce = false

local Diff = newPos - Part.Position
local Mag = Diff.magnitude 
local Direction = CFrame.new(Part.Position, newPos).lookVector

function MovePart()
    if Debounce then return end
    Debounce = true
    for n = 0, Mag, Increment do
        Part.CFrame = Part.CFrame + (Direction * Increment)
        wait( (Time/Mag) * Increment )
    end
    Debounce = false 
end

Workspace.Button.ClickDetector.MouseClick:connect(MovePart)

Doesn't work for me. Can someone help me?

2
I'm guessing you just copy-pasted this code and hoped it would work. You gotta actually understand it. For example, unless you have the exact Workspace.Button.ClickDetector and Workspace.Part hierarchy, it won't work at all. Perci1 4988 — 7y

Answer this question