Hey! There’s a bunch of reasons why this might be happening. Here are a few things you can check:
1. AssemblyLinearVelocity Resetting on Respawn:
After respawning, certain properties of the character might get reset, including AssemblyLinearVelocity
. You can fix this by ensuring the velocity is re-applied after respawn.
Solution:
Add a listener for the CharacterAdded
event to reapply the velocity when the character respawns:
-- Listen for character respawn and reapply explosion velocity
player.CharacterAdded:Connect(function(character)
local rootpart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
-- Reset AssemblyLinearVelocity to ensure it works after respawn, like ENSURE it yknow
rootpart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
end)
2. HumanoidRootPart Physics Behavior:
Sometimes, if the HumanoidRootPart
is not considered as an active physical body or if it is attached to other parts (like constraints), the velocity change might not be applied. Ensure that no constraints are blocking the physics update.
Solution:
Disable constraints before applying the velocity:
-- Disable constraints before applying the velocity
for _, constraint in pairs(rootpart:GetChildren()) do
if constraint:IsA("Constraint") then
constraint.Enabled = false
end
end
-- Now apply the velocity after disabling constraints
rootpart.AssemblyLinearVelocity = -look.LookVector * velocity
3. AssemblyLinearVelocity Application Issue:
If AssemblyLinearVelocity
is being set too soon after respawn, it might not immediately take effect. Try adding a short delay to ensure the character’s physics parts are fully initialized.
Solution:
Add a short wait before applying the velocity:
task.wait(0.1) -- Small delay to ensure character is fully initialized
rootpart.AssemblyLinearVelocity = -look.LookVector * velocity
4. Check RootPart’s Position and Orientation:
Ensure that the HumanoidRootPart
’s position and orientation are correctly being set. Sometimes, the root part might be reset or not updated as expected, which could prevent velocity changes.
Solution:
Log the root part’s position to track any unexpected changes:
print("Before setting velocity, RootPart velocity: " .. tostring(rootpart.AssemblyLinearVelocity))
rootpart.AssemblyLinearVelocity = -look.LookVector * velocity
print("After setting velocity, RootPart velocity: " .. tostring(rootpart.AssemblyLinearVelocity))
5. More Debugging and Monitoring:
Since this issue doesn’t occur in Studio, it might be related to how the game is running in an online environment. Add more detailed debugging to monitor when the velocity is set and if there are any changes to the character’s state after respawn.
Personally, I had issues with collisions in game, but not in studio. I fixed it by simply waiting for everything to load.
Solution:
Add more print statements to track the behavior and ensure the velocity is applied correctly.
Hope this helps! (it prolly wont) 