I want to script a sword weapon but I am really unsure how I would do this.
I want it to deal damage to the other players the sword may touch
But also play a custom animation (Which I have already scripted).
Can anyone help me with this?
I want to script a sword weapon but I am really unsure how I would do this.
I want it to deal damage to the other players the sword may touch
But also play a custom animation (Which I have already scripted).
Can anyone help me with this?
I’m replying in a way regarding you saying “simpliest”, but I wouldn’t do this for my own melees:
Use the roblox default tool system, track input and fire the server to handle the part doing damage and such, you can use .Touched or Region3 for detection on your sword’s hitbox, but handle these on the server only have the client handle animation and detect input.
Make a sword and insert a SCRIPT and write this
local tool = script.Parent
local function onTouch(OtherPart)
local humanoid = OtherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then return end
if humanoid.Parent == tool then return end
humanoid:TakeDamage(10)
end
tool.Activated:Connect(function()
--Play the animation here
end)
tool.Handle.Touched:Connect(onTouch)
NOTE: you must make an union of all the parts and rename it to Handle, you cannot set other name because Handle is a default ROBLOX’s name to set the sword in the player’s hand.