I was making a combat system with velocity of course but problem is when activated, assemblylinearvelocity does not go in x and z coordinates. in y coordinates, it just floats repeatted. the fix on y is to use changestate freefall. but still did i do something wrong on the velocity?
I searched many of the post including :ApplyImpulse() but still didn’t work. they acted like same.
Serverscript
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, hit, value)
local character = hit.Parent
if hit.Name == "Handle" then
character = hit.Parent.Parent
end
print(tostring(value))
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
local primarypart = character:WaitForChild("HumanoidRootPart")
local x = player.Character.PrimaryPart.CFrame.LookVector.X * value * 2
local z = player.Character.PrimaryPart.CFrame.LookVector.Z * value * 2
primarypart.AssemblyLinearVelocity = Vector3.new(x,value * 2,z)
require(game.ReplicatedStorage.ModuleScript):RigPlayer(character)
require(game.ReplicatedStorage.ModuleScript):Ragdoll(character)
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
task.wait(1)
humanoid:ChangeState(Enum.HumanoidStateType.Freefall)
humanoid.Jump = true
end)
by that i meant the instance VectorForce if u want a constant velocity, that gradually accelerates unlike linear velocity, and u can use AngularVelocity for spinning forces
It doesn’t go because perhaps you’re not calculating the knockback direction quite correctly. If you want to get the X component, then you should use RightVector.
Not sure about this, but you probably shouldn’t change the HumanoidStateType from the server since the character assembly is in the player’s network ownership (just set PlatformStand to true for Humanoid). Also, you shouldn’t change the network owner to the server, as this will lag the player as well as use the ApplyImpulse method on it.
Sorry for late reply, i will now answer your questions
the value is a strength multiplied by 2. i wanna go to the direction where the player is facing to.
I used the the LinearVelocity and tried again using RightVector, as i said the rightvelocity goes right. and the y just floats on 2 players. If you want a screen recording then i can provide.
edit: here is the code if you looking forward
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, hit, value)
local character = hit.Parent
if hit.Name == "Handle" then
character = hit.Parent.Parent
end
local strength = player.PlayerGui.Scripts.Strength
print(tostring(value))
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
local primarypart = character:WaitForChild("HumanoidRootPart")
local velocity = Instance.new("LinearVelocity")
velocity.MaxForce = math.huge
velocity.Parent = primarypart
velocity.Attachment0 = primarypart.RootRigAttachment
local x = player.Character.PrimaryPart.CFrame.RightVector.X * value * 2
local z = player.Character.PrimaryPart.CFrame.RightVector.Z * value * 2
velocity.VectorVelocity = Vector3.new(x,value * 2, z)
require(game.ReplicatedStorage.ModuleScript):RigPlayer(character)
require(game.ReplicatedStorage.ModuleScript):Ragdoll(character)
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
game.Debris:AddItem(velocity, 1)
end)
I turned off my computer sorry, I now understand the lookvector and fixed it but
the problem is the y goes up forever like zero gravity i want it to go down