Hello Everyone
I am currently making a boss fight for my game, and ran into some problems. To attack the boss in my game, players must dash towards the boss using the dash ability to damage the boss. However, when they died and eventually respawn to fight the boss again, the boss seems to not be taking damage.
I created another map to debug the codes, and manages to recreate the issue in the new map
The problem here is the AssemblyLinearVelocity.Magnitude
of the HumanoidRootPart of the player character becoming zero after respawning, even if they’re dashing forward.
Here is a video to make you understand what I’m saying (The output here is math.round(root.AssemblyLinearVelocity.Magnitude)
)
(Sorry if the quality is bad, it’s the most my computer can handle without exploding)
As you can see, the output printed out 0 after respawning. Are there anyway This can be fixed?
Scripts:
-- This is a ServerScript and is a child of a part
local Part = script.Parent
game.Players.PlayerAdded:Connect(function(plr)
char = plr.Character or plr.CharacterAdded:Wait()
root = char:WaitForChild("HumanoidRootPart")
hum = char:WaitForChild("Humanoid")
end)
Part.Touched:Connect(function(touched)
if touched.Parent then
print(math.round(root.AssemblyLinearVelocity.Magnitude))
end
end)
-- This is a LocalScript and is a child of a StarterCharacterScripts
local UIS = game:GetService("UserInputService")
-- Btw, I use ContextActionService in my actual game. UIS is for testing purposes.
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
root:ApplyImpulse(root.CFrame.LookVector * 2000)
end
end)