Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

It says eof expected near end. what does this mean?

Asked by 5 years ago
Edited 5 years ago
function onTouched(part)
    name = script.Parent.Name
        local h = part.Parent:FindFirstChild("Humanoid")
    if h ~= nil then
        char = h.Parent
        player = char:GetPlayerFromCharacter(char)
            if player ~= nil then
                leaderstats = player.FindFirstChild("leaderstats")
                if leaderstats ~= nil then
                    stage = leaderstats:FindFirstChild("Stage")
                    if stage ~= nil then
                        stage.Value = name
                    end
                end
            end
        end
    end
end

script.Parent.Touched:connect(onTouched) -- Links event to function
0
It means the script is expecting the end of the function usally it means you need to add a closed bracket to your end terence404 19 — 5y
0
I've tried SmAShHaBle 0 — 5y
0
@terence404 Examples please? SmAShHaBle 0 — 5y
0
There's an extra end there T1mes 230 — 5y
View all comments (3 more)
0
When I remove an end it still doesn't work.?? SmAShHaBle 0 — 5y
0
You're trying to call a function that isn't there on line 6 T1mes 230 — 5y
0
End of file (script) was expected near an end. Indenting saves errors. hiimgoodpack 2009 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
function onTouched(part)
    name = script.Parent.Name
        local h = part.Parent:FindFirstChild("Humanoid")
    if h ~= nil then
        char = h.Parent
        player = game:GetService("Players"):FindFirstChild(char.Name)
            if player ~= nil then
                leaderstats = player.FindFirstChild("leaderstats")
                if leaderstats ~= nil then
                    stage = leaderstats:FindFirstChild("Stage")
                    if stage ~= nil then
                        stage.Value = name
                    end
                end
            end
    end
end
-- Whatever will be touched has to be here
SpawnLocation = script.Parent -- Make sure it's the right object
SpawnLocation.Touched:Connect(onTouched)

0
@DeathGunner132 still doesnt work. SmAShHaBle 0 — 5y
0
It didnt log teh SpawnLocation1 error. I stepped on the spawn it doesnt add. I think the variables arent properly set? SmAShHaBle 0 — 5y
0
Now it says GetPlayerFromCharacter is not a valid member of model SmAShHaBle 0 — 5y
0
Edited DeathGunner132 120 — 5y
0
Should work now DeathGunner132 120 — 5y
Ad
Log in to vote
0
Answered by
T1mes 230 Moderation Voter
5 years ago
Edited 5 years ago

You put an extra end and you're trying to call a function that isn't there on line 6

function onTouched(part)
    name = script.Parent.Name
        local h = part.Parent:FindFirstChild("Humanoid")
    if h ~= nil then
        char = h.Parent
        player = char:GetPlayerFromCharacter(char) -- HERE <<<<<<<<<<<<<<<<<<<<<
            if player ~= nil then
                leaderstats = player.FindFirstChild("leaderstats")
                if leaderstats ~= nil then
                    stage = leaderstats:FindFirstChild("Stage")
                    if stage ~= nil then
                        stage.Value = name
                    end
                end
            end
        end
    end
end -- HERE <<<<<<<<<<<<<<<<<<<<<

script.Parent.Touched:connect(onTouched) -- Links event to function

you can fix this by changing the code like so:

function onTouched(part)
    name = script.Parent.Name
        local h = part.Parent:FindFirstChild("Humanoid")
    if h ~= nil then
        char = h.Parent
        player = game:GetService("Players"):FindFirstChild(char.Name)
            if player ~= nil then
                leaderstats = player.FindFirstChild("leaderstats")
                if leaderstats ~= nil then
                    stage = leaderstats:FindFirstChild("Stage")
                    if stage ~= nil then
                        stage.Value = name
                    end
                end
            end
        end
    end

p.s. put the script into the checkpoint and make sure to name the part the stage number

Log in to vote
0
Answered by 5 years ago

Your code. It’s unnecessarily long. Looks like something straight out of YouTube. Your error was on line 6 as others said, and you added an extra end. This is shortened code.

local plrs = game:GetService"Players"

function onTouch(part)
    local plr = plrs:GetPlayerFromCharacter(part.Parent)

    if plr then --You don’t need the ~= nil part, it’s redundant and does nothing
        local leaderstats = plr.leaderstats
        local stage = leaderstats.Stage
        stage.Value = script.Parent.Name
    end
end

script.Parent.Touched:Connect(onTouch) --Connect not connect

On a side note, switch to Connect, as ROBLOX may remove connect soon.

0
Nice no errors but Can you edit it so it can add +1 to the leaderstat SmAShHaBle 0 — 5y
0
@incapaz SmAShHaBle 0 — 5y

Answer this question