I have a 0 gravity game, and I want to make a script that makes it feel like you are using thrusters rather than walking. I have a script that makes your walkspeed and jumpheight 0 when you join. My problem is that the thruster script looks fine, and i’m not getting anything in output, but the script doesnt work at all.
Here is the code:
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
-- Disable walking and jumping
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
local isThrusting = false
-- Define your custom settings
local maxThrustForce = 100 -- Adjust the maximum thrust force as needed
local accelerationRate = 5 -- Rate of acceleration
-- Function to handle thrusting
local function applyThrust()
if isThrusting then
local forwardVector = character.CFrame.lookVector
local rightVector = character.CFrame.rightVector
local upVector = character.CFrame.upVector
local thrustDirection = Vector3.new(0, 0, 0)
if input.W then
thrustDirection = thrustDirection + forwardVector
end
if input.S then
thrustDirection = thrustDirection - forwardVector
end
if input.D then
thrustDirection = thrustDirection + rightVector
end
if input.A then
thrustDirection = thrustDirection - rightVector
end
if input.Space then
thrustDirection = thrustDirection + upVector
end
if input.LeftShift then
thrustDirection = thrustDirection - upVector
end
thrustDirection = thrustDirection.Unit * maxThrustForce
-- Apply a force to the HumanoidRootPart
character.HumanoidRootPart.Velocity = thrustDirection
end
end
-- Detect when a key is pressed and released
local input = {}
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.W or inputObject.KeyCode == Enum.KeyCode.S or
inputObject.KeyCode == Enum.KeyCode.A or inputObject.KeyCode == Enum.KeyCode.D or
inputObject.KeyCode == Enum.KeyCode.Space or inputObject.KeyCode == Enum.KeyCode.LeftShift then
input[inputObject.KeyCode] = true
isThrusting = true
end
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(inputObject, gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.W or inputObject.KeyCode == Enum.KeyCode.S or
inputObject.KeyCode == Enum.KeyCode.A or inputObject.KeyCode == Enum.KeyCode.D or
inputObject.KeyCode == Enum.KeyCode.Space or inputObject.KeyCode == Enum.KeyCode.LeftShift then
input[inputObject.KeyCode] = false
isThrusting = false
end
end
end)
-- Listen for constant thrusting
while true do
wait(0.1) -- Adjust this delay as needed for your desired rate of acceleration
applyThrust()
print("Thrusting:", isThrusting) -- Debugging message
print("Velocity:", character.HumanoidRootPart.Velocity) -- Debugging message
end
This is inside of the player model in the workspace. ’
If you can help me with this, you are a gigachad