You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Dash punch animation / input.
-
What is the issue? I flip around like a fish, I also eliminated all momentum after anchoring myself.
Part.Touched:Connect(function(Hit) -- Part is the hitbox around the player.
print(Hit) -- Just for bug checks
if Hit.Parent ~= Humanoid.Parent then -- If part we touch isn't apart of the players body
HRP.Anchored = true -- HumanoidRootPart.Anchored = true
force:Destroy() -- Linear force.
attachment:Destroy() -- Attachment for the linear force.
game:GetService('RunService').Heartbeat:Wait() -- Wait for one frame.
Character.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0) -- Stops all momentum???
HRP.Anchored = false -- HumanoidRootPart.Anchored = false
end
end)
- What solutions have you tried so far? Majority of things, not everything.
Heres my full script, also if you have any ways to optimize this please tell me.
local RemoteEvent = game.ReplicatedStorage.RemoteEvents.DashEvent
local function Instancer(OriginalPart, Override, Size, CanCollide)
if Override == true then
local Part = Instance.new('Part')
Part.Name = 'HitBox'
Part.Color = Color3.new(1, 0, 0)
Part.Size = Vector3.new(Size,1,Size)
Part.Position = OriginalPart.Position
Part.CanCollide = CanCollide
local Weld = Instance.new('Weld')
Weld.Part0 = Part
Weld.Parent = Part
Weld.Part1 = OriginalPart
Part.Parent = OriginalPart
return Part
else
local Part = Instance.new('Part')
Part.Name = 'HitBox'
Part.Color = Color3.new(1, 0, 0)
Part.Size = Vector3.new(OriginalPart.Size.X*1.1,OriginalPart.Size.Y*1.1,OriginalPart.Size.Z*1.1)
Part.Position = OriginalPart.Position
local Weld = Instance.new('Weld')
Weld.Part0 = Part
Weld.Parent = Part
Weld.Part1 = OriginalPart
Part.Parent = OriginalPart
return Part
end
end
RemoteEvent.OnServerEvent:Connect(function(Player, Input)
local Character = Player.Character
local Humanoid = Character:FindFirstChildWhichIsA('Humanoid')
local HRP = Character:WaitForChild('HumanoidRootPart')
local force = Instance.new("LinearVelocity", HRP)
local attachment = Instance.new("Attachment", HRP)
force.MaxForce = math.huge
force.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
force.Attachment0 = attachment
force.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
attachment.WorldPosition = HRP.AssemblyCenterOfMass
game:GetService('Debris'):AddItem(force, 0.5)
game:GetService('Debris'):AddItem(attachment, 0.5)
local Part = Instancer(HRP, true, 5, false) -- HITBOX
game:GetService('Debris'):AddItem(Part, 1)
Part.Touched:Connect(function(Hit) -- Part is the hitbox around the player.
print(Hit) -- Just for bug checks
if Hit.Parent ~= Humanoid.Parent then -- If part we touch isn't apart of the players body
HRP.Anchored = true -- HumanoidRootPart.Anchored = true
force:Destroy() -- Linear force.
attachment:Destroy() -- Attachment for the linear force.
game:GetService('RunService').Heartbeat:Wait() -- Wait for one frame.
Character.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0) -- Stops all momentum???
HRP.Anchored = false -- HumanoidRootPart.Anchored = false
end
end)
if Input == 'W' then
-- Forward
force.VectorVelocity = Vector3.new(0,0,-65)
elseif Input == 'A' then
-- Left
force.VectorVelocity = Vector3.new(-65,0,0)
elseif Input == 'S' then
-- Backward
force.VectorVelocity = Vector3.new(0,0,65)
elseif Input == 'D' then
-- Right
force.VectorVelocity = Vector3.new(65,0,0)
end
end)
-- HRP.CFrame is the position? Its also called the offset.
-- HRP.CFrame.LookVector is where the player is facing?
-- 50 is the studs.
-- HRP.CFrame is setting the position of where we are going to muliply 50 studs in the direction of the lookvector.