So, I am trying to fix this script and I'm getting the error listed above. I've looked at other answers but can't seem to figure out how to fix it! If you can help me out and tell me what's wrong and how to fix it that would be great.
Script:
local model = script.Parent
local j = game.Workspace.Test.Part1
local k = game.Workspace.Test.Part
local function onModelTouched(part)
if part:IsDescendantOf(model) then return end
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local block = stats:findFirstChild("Blocks")
block.Value = block.Value +10
wait(0.1)
script.Parent:Remove()
end
for _, child in pairs(model:GetChildren()) do
if child:IsA("BasePart") then
child.Touched:Connect(onModelTouched())
end
end

1 comment
My last answer was missing an end, sorry about that