Alright, I’m really stuck on this one, for some reason, my punching is detecting hit’s on EVERYTHING BUT OTHER PLAYERS. Now Idk why this is happening, however, I even tried welding a hitbox to every player BUT STILL it won’t detect those. Now, I have some hitboxes for training zones and those will be detected but not characters???
Code, Local Script (in the Punch tool)
--// Services
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
--// Remote Folders
local Remotes = RS.Remotes
local RemoteEvents = Remotes.Events
local ServerEvents = RemoteEvents.Server
local ToolEvents = ServerEvents.ToolEvents
--// Remote Events
local PunchEvent = ToolEvents.Punch
--// Variables
local Tool = script.Parent
local Debounce = false
--// Character Variables
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
-- Animation Vars
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Punch1Anim = Instance.new("Animation")
Punch1Anim.AnimationId = "rbxassetid://10605741632"
local Punch1AnimTrack = Animator:LoadAnimation(Punch1Anim)
Punch1AnimTrack.Priority = Enum.AnimationPriority.Action
Punch1AnimTrack.Looped = false
Punch1AnimTrack:AdjustSpeed(1)
local Punch2Anim = Instance.new("Animation")
Punch2Anim.AnimationId = "rbxassetid://10605769375"
local Punch2AnimTrack = Animator:LoadAnimation(Punch2Anim)
Punch2AnimTrack.Priority = Enum.AnimationPriority.Action
Punch2AnimTrack.Looped = false
Punch2AnimTrack:AdjustSpeed(1)
local AnimToPlayNext = Punch1AnimTrack
--// Punch 1 10605741632
--// Punch 2 10605769375
--// Functions
local function NextAnim()
if AnimToPlayNext == Punch1AnimTrack then
AnimToPlayNext = Punch2AnimTrack
elseif AnimToPlayNext == Punch2AnimTrack then
AnimToPlayNext = Punch1AnimTrack
end
end
local function OnToolActiaved()
if Debounce == false then
Debounce = true
AnimToPlayNext:Play()
NextAnim()
PunchEvent:FireServer()
task.delay(1, function()
print("Debounce reset")
Debounce = false
end)
end
end
--// Connections
Tool.Activated:Connect(OnToolActiaved)
The 2 functions in the server script that handle the damaging.
local function DealDamage(Dealer: Player, Parts: {}, BaseDmg: number, PowersMulti: number)
for _, Part: BasePart in Parts do
local Player = Players:GetPlayerFromCharacter(Part.Parent)
if Player then
local Char = Player.Character
if not Char then continue end
local Human = Char.Humanoid
Human:TakeDamage(CalcDamage(Dealer, BaseDmg, PowersMulti))
end
end
end
local function DetectDamage(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
local RightHand, LeftHand = Character.RightHand, Character.LeftHand
local PartsTouchingRightHand, PartsTouchingLeftHand = RightHand:GetTouchingParts(), LeftHand:GetTouchingParts()
print(PartsTouchingRightHand, PartsTouchingLeftHand)
local PartsAreTouchingRight, PartsAreTouchingLeft = #PartsTouchingRightHand > 0, #PartsTouchingLeftHand > 0
if PartsAreTouchingLeft then
print("Left Hand Hit", PartsTouchingLeftHand)
DealDamage(Player, PartsTouchingLeftHand, 1, 1)
elseif PartsAreTouchingRight then
DealDamage(Player, PartsTouchingRightHand, 1, 1)
print("Right hand hit", PartsTouchingRightHand)
end
end
(BTW, workspace:GetPartsInPart(RightHand, OverlapParams.new())
doesnt work either!)
Any help?