Everytime I click the button it goes to the 'No Cart Found', I'm not sure why it does that. When I test it the output (Print 'v.Name') it comes up 'Player1' and the model in game.Workspace.userCarts is named 'Player1', not sure what I've done wrong.
script.Parent.removeCart.MouseButton1Down:connect(function()
for i,v in pairs(game.Workspace.userCarts:GetChildren()) do
if v:FindFirstChild(script.Parent.Settings.User.Value) then
game.Workspace.userCarts[script.Parent.Settings.User.Value]:destroy()
script.Parent.removeCart.Text = "Cart Removed"
wait(2)
script.Parent.removeCart.Text = "Remove Cart"
else
script.Parent.removeCart.Text = "No Cart Found"
print(v.Name)
wait(2)
script.Parent.removeCart.Text = "Remove Cart"
end
end
end)

1 comment
Oh! I looked at it a second time and realize you can just run 'if game.Workspace.userCarts:FindFirstChild(script.Parent.Settings.User.Value) then' instead of a loop, way more efficient! XD Sorry, disregard my answer.