Every time I try to touch anything inside game.Workspace.Cubes it would give me an error saying Attempt to call a nil value, I don't what line is making the error but it would bring me to line 4.
local Provider = require(game.ServerScriptService.DataProvider)
local function onTouched(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
local data = Provider:Get(player)
if data then
table.insert(data.collected,#data.collection + 1,part.Name)
print("Player"..player.UserId.."Found"..part.Name)
end
end
end
for _, v in pairs(game.Workspace.Cubes:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(onTouched(v))
end
end

1 comment
Mate, you don't need the extra '(v)' in line 17.