So I'm currently making a game where you pick up orbs, which give you power (a leaderstat value) and a punching system. The only problem is the punching system does region3, making it so when I hit something, I'm in the region 3 radius, so it hits me! Is there any way I can fix this? Please help someone!
Script:
Enabled = true
Combo = 1
Action = "Combat"
script.Parent.OnServerEvent:Connect(function(Player, Action, m,Power, V1)
Enabled = true
local dmg = 10 + Power * 1
print("Got this far.")
if Enabled == false then return end
print("Got this far. 2")
if Action == Action then
print("Got this far. 3")
if Combo == 1 then
print("Got this far. 4")
Combo = 2
print("Got this far. 5")
local Track = Instance.new("Animation")
Track.AnimationId = "rbxassetid://6024898273"
Track.Name = "Anim"
local Anim = Player.Character.Humanoid:LoadAnimation(Track)
Anim:Play()
elseif Combo == 2 then
Combo = 1
local Track = Instance.new("Animation")
Track.AnimationId = "rbxassetid://6025098835"
Track.Name = "Anim"
local Anim = Player.Character.Humanoid:LoadAnimation(Track)
Anim:Play()
end
wait(0.2)
local Region = Region3.new(Player.Character.HumanoidRootPart.Position-Vector3.new(2,2,2),Player.Character.HumanoidRootPart.Position+Vector3.new(2,2,2))
print("Got this far. 6")
local RTable = workspace:FindPartsInRegion3(Region, nil, 20)
print("Got this far. 7")
for i,v in pairs(RTable) do
print("Got this far. 8")
local Deb = Instance.new("BoolValue", v.Parent)Deb.Name = "Deb"
if v.Parent:findFirstChild("Humanoid") and v.Parent:findFirstChild(Deb) == nil and v.Parent ~= Player.Character then
print("Got this far. 9")
print("Got this far. 10")
game.Debris:AddItem(Deb,0.2)
print("Got this far. 11")
v.Parent.Humanoid:TakeDamage(dmg)
print("Got this far. 12")
print("Did ".. dmg .. " damage.")
Enabled = false
end
end
end
end)
I'm having trouble on line 38. Line 38 makes it so it doesn;t hit me, but doesn't hit ANYTHING else either.
Local script (not important but for extra detail):
Player = game.Players.LocalPlayer
repeat wait() until Player.Character
Character = Player.Character
mouse = Player:GetMouse()
Tool = script.Parent
multiplier = 1
Enabled = true
Tool.Activated:Connect(function()
if Enabled == true then
script.Function:FireServer("Combat", multiplier, Player.leaderstats.Power.Value, Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-2).Position)
end
end)
No error in the output, I was just wondering, thanks!

1 comment
Does Player.Character actually refer to the character? Try to do: if v.Parent:FindFirstChild("Humanoid") and v.Parent:FindFirstChild(Deb) == nil and v.Parent ~= game.Workspace[Player.Name] then