This zoneplus zone won’t detect the models properly. Yes the names are spelt correctly in the table but it is not working.
Cheers
local Zone = require(game:GetService("ReplicatedStorage"):WaitForChild("Zone"))
local ScriptParent = script.Parent
if ScriptParent:GetAttribute("Occupied") == nil then
ScriptParent:SetAttribute("Occupied", false)
end
local BoatNames = {"Speedboat","Jetski","superski","Yacht","yacht but bufffed"}
local TouchingBoats = {}
local zone = Zone.new(ScriptParent)
local function IsBoat(Model)
if not Model then return false end
if not Model:IsA("Model") then return false end
if not Model.PrimaryPart then return false end
return table.find(BoatNames, Model.Name) ~= nil
end
local function UpdateOccupiedStatus()
ScriptParent:SetAttribute("Occupied", next(TouchingBoats) ~= nil)
end
zone.playerEntered:Connect(function(Player)
-- nothing needed for players
end)
zone.itemEntered:Connect(function(item)
if not item or not item.Parent then return end
local model = item.Parent
if IsBoat(model) then
TouchingBoats[model] = true
UpdateOccupiedStatus()
end
end)
zone.itemExited:Connect(function(item)
if not item or not item.Parent then return end
local Model = item.Parent
if TouchingBoats[Model] then
TouchingBoats[Model] = nil
UpdateOccupiedStatus()
end
end)
zone:setAccuracy(0.1)
zone.Active = true
Had the same issue and I found out that the module just breaks sometimes, I decided to make my own minimal zone module to replace zonePlus and I recommend that you do this as well or try to find another zone module.
As a quicker reply, I know you said you don’t want to switch to another module, but I’ll put what I use instead because I also had ZonePlus break on me.
ok I’ve tried to make a repro file, and I think in the code that you don’t add anything/append the table TouchingBoats. I think you need to use table.insert() here.
Try using zone.partEntered (and zone.partExited) if you haven’t registered the boat or parts of the boats as items using ZonePlus’ zone:trackItem(PutYourBoatRelatedInstancesHere).
-- enumName, enumValue, additionalProperty
-- in this case, additionalProperty is the delay between each check
return {
{"Low", 1, 1.0},
{"Medium", 2, 0.5},
{"High", 3, 0.1},
{"Precise", 4, 0.0},
}