Hello,
I am currently making a game about the Soviet manned lunar program: Soviet Moon Program - Roblox. (Do not hesitate to have a look and give me your opinion).
I reproduce the N1 rocket as well as the UR-700 rocket. Once it takes off, a module finds itself in lunar orbit. I therefore have to reproduce a zero g situation. For this I set the gravity of the square to 0. Unfortunately the player can only move forwards, backwards, left and right. I would like that when the player presses a key (for example the key “e”), this one moves upwards. And the same for moving down. I tried lots of solutions: using a jetpack, making an environment in water…
I searched on the devforum but I couldn’t find anything that answered my question (or I formulated my question badly) (I also became a member thanks to his research ;)).
Do you have any ideas to solve my problem please?
Awaiting your reply,
Aepokocmoc
1 Like
In this case you could either use UserInputService or Context Action Service.
UserInputService
ContextActionService
UserInputService
local UserInputService = game:GetService("ContextActionService")
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.E then
-- What ever you want to happen
end
end)
Context Action Service
local ContextActionService = game:GetService("ContextActionService")
local ACTION_RELOAD = "Reload"
local function handleAction(actionName, inputState, inputObject)
if actionName == ACTION_RELOAD and inputState == Enum.UserInputState.Begin then
-- What you want to happen
end
end
ContextActionService:BindAction(ACTION_RELOAD, handleAction, true, Enum.KeyCode.E)
1 Like
Thank you for your quick and efficient response! I will try these scripts and learn more about these two Services. I’m new to scripting so I don’t know where I should put the script: I guess it’s in ServiceScriptService?
This will go in the StarterCharacter scripts, for the players I believe.
1 Like