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

I'm getting an error in a script for my game and I don't know how to fix it?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm trying to run this script:

local tier = stats:findFirstChild("Tier")
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
if tier.Value == 0
    then game.ServerStorage.Tier1Sword:Clone().Parent = game.Players.LocalPlayer.Backpack
    end
    end

But I get an error message in the output: ')' expected (to close '(' at line 3) near '<eof>'

Help?

2 answers

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

Problem

What is happening is for one thing you do not have enough ends. You need one end for the if then statement on 4 and you need two ends for the functions on lines 2 and 3. You will also need a parenthesis to close the function since you're using an anonymous function.


Solution

Add that end, and put a close parenthesis to the last two ends.


Final Script

local tier = stats:findFirstChild("Tier")
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        if tier.Value == 0 then
            game.ServerStorage.Tier1Sword:Clone().Parent = game.Players.LocalPlayer.Backpack
        end
    end)
end)

Hopefully this answered your question. If so, please hit the accept answer button. If you have any questions, feel free to post them in the comments below.
Ad
Log in to vote
0
Answered by 8 years ago

It's a syntax error caused by unmatched parenthesis:

local tier = stats:findFirstChild("Tier")
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        if tier.Value == 0 then
            game.ServerStorage.Tier1Sword:Clone().Parent = game.Players.LocalPlayer.Backpack
        end
    end)
end)

Answer this question