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

How would you make a part move upon a button being clicked?

Asked by 10 years ago

I'd like to make a model, that you can sit in a seat and when pressing certain buttons, would get you to move. How to do this?

2 answers

Log in to vote
0
Answered by
6_09x 0
3 years ago

I know how to make a character move- script: local CurrentPart = nil local MaxInc = 16

function onTouched(hit) if hit.Parent == nil then return end

local humanoid = hit.Parent:findFirstChild("Humanoid")

if humanoid == nil then
    CurrentPart = hit
end

end

function waitForChild(parent, childName) local child = parent:findFirstChild(childName)

if child then
    return child
end

while true do
    print(childName)

    child = parent.ChildAdded:wait()

    if child.Name==childName then
        return child
    end
end

end

local Figure = script.Parent local Humanoid = waitForChild(Figure, "Humanoid") local Torso = waitForChild(Figure, "Torso") local Left = waitForChild(Figure, "Left Leg") local Right = waitForChild(Figure, "Right Leg")

Humanoid.Jump = true

Left.Touched:connect(onTouched) Right.Touched:connect(onTouched)

while true do wait(math.random(0.001, 3))

if CurrentPart ~= nil then
    if math.random(1, 2) == 1 then
        Humanoid.Jump = true
    end

    Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-MaxInc, MaxInc), 0, math.random(-MaxInc, MaxInc)), CurrentPart)
end

end

Ad
Log in to vote
-1
Answered by 10 years ago

you have to have a click detector in the part then script the part so when you click it is will move

0
Yes, but i want to know how to make the script, I know what to do with the click detector. r2d2inblue 0 — 10y

Answer this question