Let's image partTouching value is "Flashlight". Now look at line 15. The first variable of the list is also "Flashlight". So, when I'm comparing the two, for some reason, roblox decides that "Flaslight" and "Flashlight" are different things. Am I comparing the wrong thing? Help, please.
local detector = script.Parent local itemList = require(game.ServerScriptService:WaitForChild("Modules").ShopItems) local itemValue = script.Parent.Parent.Item local debounce = false detector.Touched:Connect(function(partTouching) if debounce == false then tostring(partTouching) local debounce = true for i = 1, #itemList do print(partTouching) print(itemList[i]) --print("something is touching") if partTouching == itemList[i] then if itemValue.Value == "" then itemValue.Value = partTouching end end end detector.TouchEnded:Wait() local debounce = false itemValue.Value = "" end end)
It's fixed. When getting the part that hits the other part, make sure to compare using part.Name. In this case, I fixed it by writing:
if itemList[i] == partTouching.Name then
Instead of
if itemList[i] == partTouching then
Hope this helps to anyone.