I am having a few problems with my sword script, I am able to do damage to dummies in the 'test world' and in the 'game itself'(I don't know their actual names) but I can't do damage to players. Here are my lines of code and additional information.
Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local SwordSwingingEvent = ReplicatedStorage:WaitForChild("SwordSwingingEvent") SwordSwingingEvent:FireServer() local CanAttack = true script.Parent.Activated:connect(function() local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack) if CanAttack == true then attack:Play() CanAttack = false wait(1) attack:Stop() CanAttack = true script.Parent.CanDamage.Value = true end end)
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local SwordSwingingEvent = ReplicatedStorage:WaitForChild("SwordSwingingEvent") SwordSwingingEvent.OnServerEvent:connect(function(player) script.Parent.blade.Touched:connect(function(hit) if script.Parent.CanDamage.Value == true then script.Parent.CanDamage.Value = false if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(30) end end wait(1) script.Parent.CanDamage.Value = true end) end)
My remote event is in the Replicated storage and labeled "SwordSwingingEvent", I added this in hopes that it would make a difference but it didn't change anything. There is also a part inside my sword labeled "blade" which covers the blade part of my sword and is supposed to do the damage. I hope I added all the information I needed to, thank you.