Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the easier way to make the position where it is and just move the Y axis?

That question might be confusing, so I will explain it here. One of my friend answered the script for CFrame, which was nice of him, and I wanted to know an easier way to make this script work without putting the exact position of where the part is. This is the script:

-- LordDragonZord and Redbullusa Script Answered
UIS = game:GetService("UserInputService") --The Service
Part = workspace.KeyBoard.AlternateKeyLeft
debounce = false --Debounce to prevent spamming

UIS.InputBegan:connect(function(key, a) --Function
    if key.KeyCode == Enum.KeyCode.A and not a and not debounce then --If pressed and debounce is false and a is false then...
        debounce = true --Debounce is true
        Part.CFrame = CFrame.new(-73.7, 21, 46.9) --Change Part's CFrame
        wait(.1) --Wait .1 seconds
        Part.CFrame = CFrame.new(-73.7, 21.5, 46.9) --Change Part's CFrame
        debounce = false --Debounce is false
    end --finished
end)

You see here on the position, where I had to copy and paste the exact position of the part in order to make the Y-axis to function. I just want to make the Y-axis function only where when I click A, it goes down 0.5 and then back up. I just want to make a script of possibly like this (X, 21, Z) wait (.1) (X, 21.5, Z). If you still don't understand, please comment it and please don't down vote since I am scared of getting suspended. Thank you.

1 answer

✓ Accepted answer

Use the current X & Z components of the CFrame of Part.

Part.CFrame = CFrame.new(Part.CFrame.X, 21, Part.CFrame.Z)
wait(.1)
Part.CFrame = CFrame.new(Part.CFrame.X, 21.5, Part.CFrame.Z)

You could also define Part's CFrame relative to its current CFrame.

Part.CFrame =Part.CFrame * CFrame.new(0, -.5, 0)
wait(.1)
Part.CFrame =Part.CFrame * CFrame.new(0, .5, 0)

2 comments

0

Thanks Red bro.

0

You're welcome ^^

This discussion is preserved as it was. New answers, comments, and votes are closed.