Script doesnt print when the string value doesn't exist but throws a error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want this script to check if the the string value has nothing or something in it

  2. What is the issue?
    Screenshot 2023-06-19 001913

local CollectionService = game:GetService("CollectionService")
local SellaPart = CollectionService:GetTagged("Sell")
local Debounce = {}

for _, SellPart in SellaPart do
    SellPart.Touched:Connect(function(Hit)
        local Character = Hit.Parent
        local Humanoid = Character:FindFirstChild("Humanoid")
        local Stroller = Character:FindFirstChild("Stroller")
        if Humanoid and not Debounce[Character] then
            Debounce[Character] = true
            if Stroller.StrollerPerson.Value == nil then
                print("No one is in the Stroller")
            else
                for _, Player in workspace:GetChildren() do
                    if Player.Name == Stroller.StrollerPerson.Value then
                        print(Stroller.StrollerPerson.Value)                        
                    end
                end
            end
            wait(.5)
            Debounce[Character] = false
        end
    end)
end
1 Like

Stroller is not a child of Hit.Parent. You might want to try :WaitForChild() instead of :FindFirstChild() if you know for a fact it will be there. You may also want to try checking for it instead in the if statement as the function would still fire if anything touches it