hello!!! im recreating the jetpack ability from bombrush cyberfunk needing help of how i could make this pls:
when the player presses shift they automaticly go forward w/out needing to press w
when they turn the turnspeed is slow like drifting?
im kinda new to scripting srry if this isnt informative enough
This might be a tough starting project for a new scripter.
Click the following links to get to the Roblox Documentation on each item. Sometimes there are more than just one link.
UserInputService will take care of the shift input.
Putting a VectorForce class (VectorForce) in the Player, controlled by the shift input will thrust you forward.
Putting a Torque class (Torque) in the player should rotate the player.
i used an alternative by changing the physicalproperties to 0 0 0 0 100 (high value of density)
to achieve the speed and drift effect however i encountered these issues:
1 the player gets killed in the void when toggled in the air
2 the player flings off at the wedge
is there someway to fix this?
the script:
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local UserInputService = game:GetService(“UserInputService”)
local TweenService = game:GetService(“TweenService”)
local Bar = script.Parent.Frame.Bar
local Sprinting = false
local stamina = script.Parent.Settings.MaxStamina.Value
local Humanoid = player.Character:FindFirstChildWhichIsA(“Humanoid”)
if not Humanoid then
repeat
wait()
Humanoid = player.Character:FindFirstChildWhichIsA(“Humanoid”)
until Humanoid
end
– Function to set physical properties
local function setPhysicalProperties(character, density, friction, elasticity, frictionWeight, elasticityWeight)
for _, part in ipairs(character:GetChildren()) do
if part:IsA(“BasePart”) then
part.CustomPhysicalProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
end
end
end
UserInputService.InputBegan:Connect(function(Key, Processed)
if Key.KeyCode == Enum.KeyCode.LeftShift and Processed == false then
Humanoid.WalkSpeed = script.Parent.Settings.SprintSpeed.Value
Sprinting = true
setPhysicalProperties(player.Character, 0, 0, 0, 0, 100) – Set custom physical properties
while stamina > 0 and Sprinting do
stamina = stamina - 1
Bar.Size = UDim2.new(stamina / script.Parent.Settings.MaxStamina.Value, 0, 1, 0)
TweenService:Create(camera, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {FieldOfView = 90}):Play()
wait(0.1) -- Added a small wait to prevent excessive loop cycles
if stamina <= 0 then
Humanoid.WalkSpeed = 16
setPhysicalProperties(player.Character, nil) -- Reset physical properties
end
end
end
end)
UserInputService.InputEnded:Connect(function(Key, Processed)
if Key.KeyCode == Enum.KeyCode.LeftShift and Processed == false then
Humanoid.WalkSpeed = 16
Sprinting = false
setPhysicalProperties(player.Character, 100, 0, 0, 0.3 ,1) – Reset to default physical properties immediately
TweenService:Create(camera, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {FieldOfView = 70}):Play()
while stamina < script.Parent.Settings.MaxStamina.Value and not Sprinting do
stamina = stamina + 1
Bar.Size = UDim2.new(stamina / script.Parent.Settings.MaxStamina.Value, 0, 1, 0)
wait(0.1) -- Added a small wait to prevent excessive loop cycles
end
end
end)
Why are you setting Density
to 100? You also seem to be resetting the Density
, Elasticity
, and the ElasticityWeight
properties.
As far as I know a players Parts are all around Density 0.7 as Default (1 is the Density of Terrain Water so players can float).
You have parameters of 0, 0, 0, 0, 100 and 100, 0, 0, 0.3, 1
wait()
has been replaced by task.wait()
recently.
i found a different forum related to physical properties, but i will try taking your advice!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.