I created a script that SHOULD only destroy things in the folder but it is destroying every part in the game. Here is the script:
local Folder = game.Workspace.TrashCollection
local playerInBoat = false
local player = workspace.YellowBoat.Drive.Occupant
workspace.YellowBoat.Drive:GetPropertyChangedSignal("Occupant"):Connect(function()
if workspace.YellowBoat.Drive.Occupant then
playerInBoat = true
end
end)
local trashcollector = workspace.YellowBoat.Boat.TrashCollectors
trashcollector.Touched:Connect(function(hit)
if hit.Parent == Folder and hit:IsA("Model") or hit:IsA("BasePart") and playerInBoat then
if playerInBoat == true then
game.Players:GetPlayerFromCharacter(workspace.YellowBoat.Drive.Occupant.Parent).leaderstats.Trash.Value += 1
hit:Destroy()
end
end
end)
I think it could be because of the “or” here, try to change that line with :
if hit.Parent == Folder and hit:IsA(“Model”) or hit.Parent == Folder and hit:IsA(“BasePart”) and playerInBoat then