Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to fix the error "'end' expected (to close 'function' at line 5) near '<eof>'" in this script?

Asked by
IsPoyo -1
3 months ago

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
0
My last answer was missing an end, sorry about that cmgtotalyawesome 974 — 3mo

Answer this question