--Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--Remote events
local hitStart = ReplicatedStorage:WaitForChild("HitStart")
--Why I have hitEnd still I don't know. WholeSwingEnd is the right one.
local hitEnd = ReplicatedStorage:WaitForChild("HitEnd")
local wholeSwingEnd = ReplicatedStorage:WaitForChild("WholeSwingEnd")
--Variables - Some are useless I know
--The booloean is a value because if not, when, say, another person swings down, you
--will be able to do damage too. We need the booleans seperate, so this I did
--Well there is a BIG problem - it still refers to same one. I will make it a name
--Ok so if there is a name, it is true
local hittingStick = script.Parent
local hittable = hittingStick.Hittable
local stickDamage = 20
local stick = hittingStick.Top
local backpack = hittingStick.Parent
local owner = backpack.Parent
local hasBeenHit = false
owner.Parent = Players
hittable.Name = owner.Name
local function onHitAttack()
--Hittable is true when hitAttack(swingdown) starts
hittable.Name = owner.Name
--If touched when hittable is true and it is player, damage player
stick.Touched:Connect(function(part)
local partParent = part.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid and hittable.Name == owner.Name then
humanoid:TakeDamage(stickDamage)
hittable.Name = ""
end
end)
--If end of swing comes, damage can no longer happen
hitEnd.OnServerEvent:Connect(function()
--This is too fast, compared to touched event, so we must put wait to let touched conditions go first
wait(0.3)
hittable.Name = ""
end)
wholeSwingEnd.OnServerEvent:Connect(function()
--To be honest what do I put here?
end)
end
--During swingdown damage can occur
hitStart.OnServerEvent:Connect(onHitAttack)
Ummm. So what happens is when someone hits another player, the enemy player gets damaged, but at the same time the other player weapon is able to damage, even if the animation is not running. This is because when I make a value true in the script, all values like that become true. In this part, I tried to use name conditions but they also did not work. How would I specify a value or thing. The value is a BoolValue, although before it wasn't. I still have comments from before...…. This is in a script. Both values are same all the time.

1 comment
remember to mark it as [solved]