Alright, First post. So I am working on a ability for a MHA game, this ability is stronger than a normal punch but also should blow your opponent back. Everything has been working perfectly other than the blowing them back part.
script.Parent.Touched:Connect(function(hit)
local plrname = script.Parent.Parent.Name
local char = hit.Parent
local hum = char:FindFirstChild("Humanoid")
if hum and char.Name ~= script.Parent.Parent.Name then
hum.Health = hum.Health - script.Dmg.Value
if char:FindFirstChild("AI") then
if hum.Health <= char.AI.KillHP.Value and char:FindFirstChild("PlrWhoKilled") == nil then
local Va = Instance.new("StringValue")
Va.Value = plrname
Va.Name = "PlrWhoKilled"
Va.Parent = char
end
end
local y = Instance.new("BodyVelocity")
y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
y.Velocity = script.Parent.Parent.HumanoidRootPart.CFrame.lookVector * 100
y.Parent = hit.Parent.UpperTorso
game.Debris:AddItem(y,1)
local yolo = game.ServerStorage.Meshes.V1:Clone()
yolo.Size = Vector3.new(1,1,0.05)
yolo.BrickColor = BrickColor.new("Institutional white")
yolo.CanCollide = false
yolo.Anchored = true
yolo.Material = "Neon"
yolo.Transparency = 0.6
game.Debris:AddItem(yolo, 2)
yolo.CFrame = script.Parent.Parent.Head.CFrame * CFrame.new(0,0,0) *CFrame.Angles(math.rad(0),0,0)
local Vaa = script.Wave
Vaa.Parent = yolo
yolo.Parent = game.Workspace
Vaa.Disabled = false
script.Disabled = true
wait(0.5)
end
end)
But then the issue appears and it just simply does not work, no errors or anything. I looked in the explorer it does put the velocity in the players Torso its just it does not move them. Could it be because they are dummys / rigs and not players?
Hey if I typed my code in the wrong format please tell me as I forgot how exactly I was suppose to put it.
This is before changing its parent to the players right hand. DmgScript is the script I provided above. Please remember everything but the knock back works. And if you want to see after its been parented then just ask
I just looked and that end at the bottom, it was the end for
if hum and char.Name ~= script.Parent.Parent.Name then
That if statement made it so you did not use the move on yourself or something that’s not living. So if we moved the end and the player punches a wall then its going to send the wall flying. This is why I choose to put it at the bottom so the moving ect only happen on a NPC or player.
Maybe math.huge is just bugging? Or maybe the script isn’t picking up the humanoidRootPart and isn’t letting you know? Try printing the rootpart with the lookVector and manually changing the math.huge to just large numbers.
Edit: Maybe also try putting script.Parent.Parent.HumanoidRootPart.CFrame.lookVector * 100 in parentheses
So I just tested again and I was messing with it and the dummy (Hes standing still and is made from the animation plugin) im testing it. When I hit him he stays still and I can see the velocity in his body. The thing is its saying his HumanoidRootPart is anchored, is this normal? Next, the moment I unanchor his rootpart he blows back.
BodyVelocity only works on unanchored objects (since it only forcefully changes velocity and not position/CFrame). Also that means anything welded to the anchored object can’t move either.