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
It says eof expected near end. what does this mean?
3 answers
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)
5 comments
@DeathGunner132 still doesnt work.
It didnt log teh SpawnLocation1 error. I stepped on the spawn it doesnt add. I think the variables arent properly set?
Now it says GetPlayerFromCharacter is not a valid member of model
Edited
Should work now
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
###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.
2 comments
Nice no errors but Can you edit it so it can add +1 to the leaderstat
@incapaz
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
It means the script is expecting the end of the function usally it means you need to add a closed bracket to your end
I've tried
@terence404 Examples please?
There's an extra end there
When I remove an end it still doesn't work.??
You're trying to call a function that isn't there on line 6
End of file (script) was expected near an end. Indenting saves errors.