Hey! I’ve been trying to make a boat system, but due to spam, I have tried to limit the amount of boats allowed in one area with this code. However, the ‘Touched’ function also detects players. I have created this code to combat this, but it still registers as touched. Could someone please tell me the problem?
local part = workspace.BoatCheckArea
local touching = 0
local function onPartTouched(otherPart)
if not otherPart.Parent:FindFirstChildWhichIsA("Humanoid") then
touching = 1
end
end
local function onPartFinishedTouching(otherPart)
if not otherPart.Parent:FindFirstChildWhichIsA("Humanoid") then
touching = 0
end
end
part.Touched:Connect(onPartTouched)
part.TouchEnded:Connect(onPartFinishedTouching)
local part = workspace.BoatCheckArea
local touching = 0
local function onPartTouched(otherPart)
if otherPart.Parent:FindFirstChildWhichIsA("Humanoid") then
else
touching += 1
end
end
local function onPartFinishedTouching(otherPart)
if otherPart.Parent:FindFirstChildWhichIsA("Humanoid") then
else
touching = 0
end
end
part.Touched:Connect(hit)
onPartTouched(hit)
end
part.TouchEnded:Connect(hit)
onPartFinishedTouching(hit)
end