Good day,
the issue I have right now is that I am doing a combat system, and right now doing it with a Sword.
So, this is how it works;
This makes damage and the touched event.
------------------------ Touched Sword to start
Player.Character:WaitForChild("Sword", 1000000000).Hitbox.Touched:Connect(function(Hit)
print("found")
local Sword = Player.Character:WaitForChild("Sword")
print(Sword)
print(Sword.Parent)
print(Sword.Hitbox)
print("it hit")
if Hit.Parent:FindFirstChild("Humanoid")
and not Damaged
and not Debounce
and Hit.Parent.Humanoid ~= Player.Character.Humanoid then
if Player.Character.Humanoid.Health > 0 then
if DebounceLight == false then
Damaged = true
if LightAnimationNumber == 2 then
game.ReplicatedStorage:FindFirstChild("Combat System").LightCombat1:FireServer(Hit.Parent.Humanoid)
end
end
end
end
end)
This triggers the animation.
game:GetService("UserInputService").InputBegan:Connect(function(Input, Event)
if Event then return end
local PlayerVelocity = Player.Character.HumanoidRootPart.Velocity.magnitude
if Input.KeyCode == Enum.KeyCode.E and DebounceLight then
DebounceLight = false
Debounce = false
if LightAnimationNumber == 1 and Player.WeaponEquipped.Value == "Sword" then
game.ReplicatedStorage:FindFirstChild("Combat System").CreateWelds:FireServer(Player)
local playAnimation = Player.Character:WaitForChild("Humanoid"):LoadAnimation(Unsheathe)
playAnimation:Play()
wait(0.6)
Damaged = false
DebounceLight = true
Debounce = true
LightAnimationNumber = LightAnimationNumber + 1
---------------------- Unsheathed
elseif LightAnimationNumber == 2 and Player.WeaponEquipped.Value == "Sword" then
print("it enable")
print("slah!")
local playAnimation = Player.Character:WaitForChild("Humanoid"):LoadAnimation(SwordSlash)
playAnimation:Play()
wait(0.6)
Damaged = false
DebounceLight = true
Debounce = true
end
if LightAnimationNumber >= 3 then
LightAnimationNumber = 2
end
end
end)
And here is the Server Script with re RemoteEvent.
game.ReplicatedStorage:FindFirstChild("Combat System").LightCombat1.OnServerEvent:Connect(function(Player, Humanoid)
Humanoid.Health = Humanoid.Health - 90
Player.Character.Head.LightPunch:Play()
end)
So, when the player gets the sword, the touched event works. It works (the printing, until it finds the humanoid (as I try the touchedevent with blocks and not humanoids)) until you press āEā, as it loads the animation. Then, the touch event stops working and does not print anything.