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

What am I doing wrong here? *Edited*

Asked by 8 years ago

I haven't scripted for a while and I am actually a beginner still. Well, anyway, I am working on a script where when I click the "Push" it will go up to the position I put and when I click it again, it will go down to the position that I put plus making the ParticleEmitter enabled as well for just a second and then off. I hope you understand what I mean.

-- Push up = -154.205, 22.023, -13.131
-- Push down = -154.205, 21.343, -13.131

push = game.Workspace.Pump.Push
air = game.Workspace.Pump.PumpOut.ParticleEmitter
debounce = false
pumpon = false

function onClicked()
    if debounce then return end
    debounce = true
    if pumpon then
        pumpon = true
        push.Position = push.CFrame(push.CFrame.X, 21.343, push.CFrame.Z)
        air.Enabled = true
        wait(1)
        air.Enabled = false
    else -- Your expression was redundant and likely a typo
        pumpon = false
        push.Position = push.CFrame(push.CFrame.X, 22.023, push.CFrame.Z)
    end
    debounce = false -- You forgot to disable the debounce after the movement
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
Any errors in the output? Scootakip 299 — 8y
0
Change your elseif to just an else GoldenPhysics 474 — 8y
0
@Skootakip, no there isn't any errors RobotChitti 167 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Your issues are in the OnClicked,

function onClicked()
    if debounce then return end
    debounce = true
    if pumpon then
        pumpon = false
        pump.Position = pump.CFrame(pump.CFrame.X, 21.533, pump.CFrame.Z)
    else -- Your expression was redundant and likely a typo
        pumpon = true
        pump.Position = pump.CFrame(pump.CFrame.X, 22.023, pump.CFrame.Z)
        air.Enabled = true
        wait(1)
        air.Enabled = false
    end
    debounce = false -- You forgot to disable the debounce after the movement
end
Ad

Answer this question