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

Expected end when closing function got <eof>?

Asked by
8jxms 9
4 years ago
Edited by royaltoe 4 years ago

At first my ends worked perfectly and suddenly they broke. It is in a regular script. Here is my script(it's from an AlvinBlox tutorial bc i suck at stats):

local serverStorage = game:GetService("ServerStorage")
local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerSaveData")

game.Players.PlayerAdded:Connect(function(player)


    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local strength = Instance.new("NumberValue")
    strength.Name = "Strength"
    strength.Parent = leaderstats

    local rebirths = Instance.new("IntValue")
    rebirths.Name = "Rebirths"
    rebirths.Parent = leaderstats

    local dataFolder = Instance.new("Folder")
    dataFolder.Name = player.Name
    dataFolder.Parent = serverStorage.RemoteData

    local debounce = Instance.new("BoolValue")
    debounce.Name = "Debounce"
    debounce.Parent = dataFolder

    local strengthData, rebirthsData

    local success,errormessage = pcall(function()
        strengthData = DataStore:GetAsync("strength-"..player.UserId)
        rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)

    if success then
        if strengthData then
            strength.Value = strengthData
            rebirths.Value = rebirthsData
        end 
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local success, errormessage = pcall(function()
        DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Strength.Value)
        DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Strength.Value)
    end)
end)

1 answer

Log in to vote
0
Answered by
NotedAPI 810 Moderation Voter
4 years ago
Edited 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Hey!

Try this. I added two ends one with a ) and one without it.

game.Players.PlayerAdded:Connect(function(player)


    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local strength = Instance.new("NumberValue")
    strength.Name = "Strength"
    strength.Parent = leaderstats

    local rebirths = Instance.new("IntValue")
    rebirths.Name = "Rebirths"
    rebirths.Parent = leaderstats

    local dataFolder = Instance.new("Folder")
    dataFolder.Name = player.Name
    dataFolder.Parent = serverStorage.RemoteData

    local debounce = Instance.new("BoolValue")
    debounce.Name = "Debounce"
    debounce.Parent = dataFolder

    local strengthData, rebirthsData

    local success,errormessage = pcall(function()
        strengthData = DataStore:GetAsync("strength-"..player.UserId)
        rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)
    end)

    if success then
        strength.Value = strengthData
        rebirths.Value = rebirthsData
   end
end)
0
thanks for trying to help but it didn't work. I've tried so many combinations and still get and error. If you need it, here is the error message I received when doing that: <font color="red">Error: (38,5) Expected identifier when parsing expression, got ')'</font> 8jxms 9 — 4y
0
try now. that font bit wasnt supposed to be there royaltoe 5144 — 4y
0
I made a edit to the script, try it now NotedAPI 810 — 4y
0
ugh still wont work 8jxms 9 — 4y
View all comments (2 more)
0
add me on Discord xWhiteHat#4788 NotedAPI 810 — 4y
0
k i did 8jxms 9 — 4y
Ad

Answer this question