✓ Accepted answer
I have got a super easy way to code swords and it doesnt take much effort
so step number 1 is to insert a on touch damage script into the blade. The script should look lie this:
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
human.Health = human.Health - 50
end
end
script.Parent.Touched:connect(onTouched)
and set the script to disabled
now,you want to insert 2 sounds into the tool, a equip sound and a knife slash sound.
then just insert a normal script into the tool and type in this
script.Parent.Equipped:connect(function()
script.Parent.Knife_Equip:Play()
end)
script.Parent.Activated:connect(function()
script.Parent.Blade["Damage Script"].Disabled = false
script.Parent.Knife_Slash:Play()
script.Parent.GripForward = Vector3.new(0,5,- 1)
end)
script.Parent.Deactivated:connect(function()
script.Parent.Blade["Damage Script"].Disabled = true
script.Parent.GripForward = Vector3.new(0,0,- 1)
end)
then insert another normal script into the tool and this script will be for welding so type in this:
function weld()
local parts,last = {}
local function scan(parent)
for _,v in pairs(parent:GetChildren()) do
if (v:IsA("BasePart")) then
if (last) then
local w = Instance.new("Weld")
w.Name = ("%s_Weld"):format(v.Name)
w.Part0,w.Part1 = last,v
w.C0 = last.CFrame:inverse()
w.C1 = v.CFrame:inverse()
w.Parent = last
end
last = v
table.insert(parts,v)
end
scan(v)
end
end
scan(script.Parent)
for _,v in pairs(parts) do
v.Anchored = false
end
end
weld()
script:Remove()
I hope this answer helped! :3
6 comments
loop through the players and use magnitude if their in range
Well.... That doesn't help...
At least put the script on your question.
i should say the same, magnitude work pretty well.
What's wrong with what you have? Confused
use the idea i gave u to try replicate what u want to do