0
votes

I made a cash for kill script in Roblox, but wanted to go further than that and implement a script where when a player has a gamepass, then that player would recieve more cash than another normal player would.

This is for a battle royale styled game in Roblox, and when I playtested it, there were no errors, but the script didn't work.

game.Players.PlayerAdded:connect(function(player)
    local folder = Instance.new("Folder",player)
    folder.Name = "leaderstats"
    local currency1 = Instance.new("IntValue",folder)
    currency1.Name = "Cash"

    local increment = 50

    if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,7382818)then 
        increment = increment + 50
    end

    player:WaitForChild("Humanoid").Died:connect(function()
        local tag = player.Humanoid:FindFirstChild("creator")
        if tag ~= nil then
            local killer = tag.Value
            if killer ~= nil then
                -- Find the killer's leaderstats folder
                local killerStats = killer:FindFirstChild("leaderstats")

                if killerStats ~= nil then
                    -- Find the killer's Cash IntValue
                    local killerCash = killerStats:FindFirstChild("Cash")

                    -- Increase cash as before
                    killerCash.Value = killerCash.Value + increment
                end
            end
        end
    end)

I expected a VIP player, who has the gamepass, to receive more cash, but when I tested it, no player received any cash for killing another player at all.

1
You did not close the outer (or the inner) functionEgor Skriptunoff
you close player:WaitForChild("Humanoid").Died:connect(function() with end) but you do not close game.Players.PlayerAdded:connect(function(player) with end)Andrew Kashpur

1 Answers

1
votes

How to fix an end expected error near eof

If the Lua interpreter complains about a missing end you`re missing it somewhere.

Read through your code and make sure everything that is supposed to be closed with an end has one. Read through the Lua Reference Manual to find out which keywords need an end.

In your code it's if statements and function definitions. Checking each pair from inside out you'll end up one end) short to close this game.Players.PlayerAdded:connect(function(player) as mentioned in the comments.