Currently I have been trying to figure out how would the sword deal damage, I don’t really know how would I accomplish this since what I did was use local script for the animations.
I was thinking that I’ll just use the local script to check if the sword touched anything and send it to the server to deal damage, but then that would just make exploiter abuse it and just send misinformation to deal damage.
Then I also thought of just use the server to play the animation, but all the timing are wrong
Then I though of just use remote function and just use sever-client-server but if the client made an error then that would just break the server script.
All I need is just an idea of how I would implement it.
--Variables
local Tool = script.Parent
local Player = Tool:FindFirstAncestorWhichIsA("Player")
local Handle = Tool.Handle
local t = script:WaitForChild("Attack")
local db = false
local hit = {}
local Debris = game:GetService("Debris")
local Conf = Tool.Configuration
local cooldown = Conf.Cooldown
local wt = Conf.WeaponType
--This will let us get gold and stuff when the target is killed by us
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
if not humanoid:FindFirstChild("creator") then
Creator_Tag.Parent = humanoid
end
end
Tool.Activated:Connect(function()
if db == false then
db = true
local Humanoid = Tool.Parent:WaitForChild("Humanoid")
local AnimTrack = Humanoid:LoadAnimation(t)
AnimTrack:Play()
task.wait(cooldown.Value)
db = false
end
end)
Handle.Touched:Connect(function(Hit)
local num = math.random(1,2)
if num == 1 then
if not game:GetService("Players"):FindFirstChild(Hit.Parent.Name) then
local TeamValue = Hit.Parent:FindFirstChild("TeamV")
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Tool.Parent and TeamValue.Value ~=Player.TeamColor then
if db == true and hit[Hit.Parent] == nil then
local extradmg = Player.leaderstats.SwordExtra
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage((Conf.Damage.Value + ((extradmg.Value/100)*Conf.Damage.Value)))
local c = game:GetService("ServerStorage"):WaitForChild("RiddlingSkull"):Clone()
if not Hit.Parent:FindFirstChild(c.Name) then
c.Parent = Hit.Parent
local fire = Instance.new("Fire")
fire.Parent = c.Handle
fire.Color = Color3.fromRGB(255, 219, 192)
fire.SecondaryColor = Color3.fromRGB(255, 170, 0)
spawn(function()
for i = 1,5 do
Hit.Parent.Humanoid.Health -= 2 * i
task.wait(1)
end
end)
end
TagHumanoid(Hit.Parent.Humanoid,Player)
spawn(function()
task.wait(3.1)
c:Destroy()
end)
hit[Hit.Parent] = true
wait(cooldown.Value)
hit[Hit.Parent] = nil
end
end
else
--PLAYER
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name ~= Player.Name and game.Players[Hit.Parent.Name].Team.Name ~=Player.Team.Name then
if db == true and hit[Hit.Parent] == nil then
local resis = game.Players[Hit.Parent.Name].leaderstats.Resist
local extradmg = Player.leaderstats.SwordExtra
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage((Conf.Damage.Value + ((extradmg.Value/100)*Conf.Damage.Value)) - (resis.Value/100 * Conf.Damage.Value))
local c = game:GetService("ServerStorage"):WaitForChild("RiddlingSkull"):Clone()
c.Parent = Hit.Parent
TagHumanoid(Hit.Parent.Humanoid,Player)
spawn(function()
task.wait(2.3)
c:Destroy()
end)
hit[Hit.Parent] = true
wait(cooldown.Value)
hit[Hit.Parent] = nil
end
end
end
else
if not game:GetService("Players"):FindFirstChild(Hit.Parent.Name) then
local TeamValue = Hit.Parent:FindFirstChild("TeamV")
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Tool.Parent and TeamValue.Value ~=Player.TeamColor then
if db == true and hit[Hit.Parent] == nil then
local extradmg = Player.leaderstats.SwordExtra
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage((Conf.Damage.Value + ((extradmg.Value/100)*Conf.Damage.Value)))
TagHumanoid(Hit.Parent.Humanoid,Player)
hit[Hit.Parent] = true
wait(cooldown.Value)
hit[Hit.Parent] = nil
end
end
else
--PLAYER
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name ~= Player.Name and game.Players[Hit.Parent.Name].Team.Name ~=Player.Team.Name then
if db == true and hit[Hit.Parent] == nil then
local resis = game.Players[Hit.Parent.Name].leaderstats.Resist
local extradmg = Player.leaderstats.SwordExtra
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage((Conf.Damage.Value + ((extradmg.Value/100)*Conf.Damage.Value)) - (resis.Value/100 * Conf.Damage.Value))
TagHumanoid(Hit.Parent.Humanoid,Player)
hit[Hit.Parent] = true
wait(cooldown.Value)
hit[Hit.Parent] = nil
end
end
end
end
end)
All you need to do,
is simply do your animation , and when its over, use a simple Touched event and detect what was the object that touched that sword, and use either TakeDamage(), or BreakJoints(), or just set their HP to 0.
even if you animate on the server side and listen for touches on the server side exploiters can still abuse it
here is a video showing you how
the way i would do it is
animate on the client side and sending a remote event if the sword touches the target
then the server will use the anti hack that is in my video to check if the player is standing close to the target it want to hit and if the player is within lets say 10 studs i would deduct the health from the target
Yeah the thing is I’m not really using a tool just a model and it’s not just a single animation, it’s like a combo, so I’m using multiple animation and after the animation ends there’s like a little detail’s of animation where if the player stop’s attacking/clicking the attack animation continues like for example flipping the sword etc.