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

Model Move Help? [2] [closed]

Asked by 10 years ago

This question already has an answer here:

C-Frame a Model down?

I'm trying to make a Model slowly move down for 3 seconds. Thank's to whoever helped me on the first question, but I just need it to slowly move down for 3 seconds, but I have to keep clicking it and it moves like 2 studs down:

function onClicked(playerWhoClicked)

local model = workspace.Tuner1.Lift --Model to move
local part = model:GetChildren()[1]
model.PrimaryPart = part

for i = 1,1,.01 do
    wait(i)
    model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() - Vector3.new(0,3,0))
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Marked as Duplicate by Goulstem, Redbullusa, and EzraNehemiah_TF2

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

Please do not double post.

The problem is that you didn't have a debounce to your script, as well as the fact that you were waiting i seconds before re-iterating.. if you do that then the script will wait a lot more than it should before subtracting CFrames again.

local model = workspace.Tuner1.Lift --Model to move
local part,db = model:GetChildren()[1],false
model.PrimaryPart = part

script.Parent.ClickDetector.MouseClick:connect(function()
    if db == false then
        db = true
        for i = 1,100 do
            wait()
            model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() - Vector3.new(0,.03,0))
        end
    db = false
    end
end)
0
Ok, but what if I wanted it to automatically go down? With that one I have to spam click it ScriptingHelpersALT 20 — 10y
0
My bad, the for loop on line 8 was messed up. Try my edit. Goulstem 8144 — 10y
0
Ok, so to stop it, it would be wait(3) then CFrame 0,0,0? ScriptingHelpersALT 20 — 10y
0
What? No, it will stop automatically. Goulstem 8144 — 10y
View all comments (2 more)
0
Er, it doesn't ScriptingHelpersALT 20 — 10y
0
Nevermind, thank you. ScriptingHelpersALT 20 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago
function onClicked(playerWhoClicked)

local model = workspace.Tuner1.Lift --Model to move
local part = model:GetChildren()[1]
model.PrimaryPart = part

for i,v in pairs = 1,1,.01 do
    wait(i)
    model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() - Vector3.new(0,3,0))
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

0
I put for i,v in pairs so since the numbers 1,1 are pairs iDoctorW 0 — 10y
0
Ok, but Error on line 7? And yes, I made the = a == . ScriptingHelpersALT 20 — 10y
0
Line 7 is incorrect syntax. Use a numerical for loop. Goulstem 8144 — 10y