So, yes, I still working on sword fighting. A lot of people helped me. ANYWAYS, this isn’t the thing going on here, I am still working on Sword Area Regions, I tried to use some regions online and I made but none of them worked, I also tried using touched events:
local IsTouching = false
script.Parent.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild('Humoniod')
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if hum and not IsTouching then
IsTouching = true
hit.Parent:FindFirstChild('Humoniod'):EquipTool (plr.Backpack.ClassicSword)
end
end)
script.Parent.TouchEnded:Connect(function(hit)
local hum = hit.Parent:FindFirstChild('Humoniod')
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if hum and not IsTouching then
IsTouching = true
hit.Parent:FindFirstChild('Humoniod'):UnequipTools()
end
end)
Touch Ended is very unreliable and I suggest you could use stuff like :GetTouchingParts()
local function CheckIfHumanoid(part)
local connection = part.Touched:Connect(function()end)
local checking = part:GetTouchingParts()
connection:Disconnect()
return checking
end
while true do
local checkedAns = CheckIfHumanoid(workspace.GiveSwordRegion)
--print(#checkedAns)
for i,v in pairs(checkedAns) do
--print(v.Name)
if v:FindFirstChild('Humanoid') then
print('giving player sword')
if v:FindFirstChild('Sword') then
-- player already got a sword so just stop
else
-- No sword found
local cloneSword = game.ServerStorage.Sword:Clone()
cloneSword.Parent = v
end
end
end
wait(1)
end
There might be some problems so maybe don’t just copy and paste