You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I’m trying to make a weapon that will knock players back when it touches them using Roblox’s VectorForce. -
What is the issue?
The player is not being knocked back, yet they are being touched. -
What solutions have you tried so far?
I have looked through various other posts and the Roblox Documentation, but could not figure out how to correctly use VectorForces.
local tool = script.Parent
local blade = tool.Handle.Sword_Part
local debounce = false
local function touched(hit)
if not debounce then
debounce = true
if hit.Parent:FindFirstChild("Humanoid") then
print(hit)
local humanoid = hit.Parent.Humanoid
local humanoidRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
if humanoid and humanoidRootPart then
local attachment = Instance.new("Attachment", humanoidRootPart)
local force = Instance.new("VectorForce", humanoidRootPart)
force.Attachment0 = attachment
force.Force = Vector3.new(0,0,1000)
wait(1)
force:Remove()
attachment:Remove()
end
end
debounce = false
end
end
blade.Touched:Connect(touched)