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 theParticleEmitter
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)
First, it helps if you give errors and output, and explain what is actually happening.
-- 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 = Vector3.new(push.CFrame.X, 21.343, push.CFrame.Z) -- See below 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) -- Needs to be a Vector3 for Position. push.Position = Vector3.new(push.CFrame.X, 22.023, push.CFrame.Z) -- Alternatively, -- push.CFrame = 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)
The issue is that you
CFrame.new
Position
to a CFrame value.