Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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 ''

Help?

2 answers

✓ Accepted answer

##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.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.