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

Im trying to make a script to check players tool but i get an error?

local ToolName = "FlashLight"

while true do
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Player.Backpack:FindFirstChild(ToolName) then
			workspace.BARRIER.Position = Vector3.new(20, 0.5, 45.32)
		else
			workspace.BARRIER.Position = Vector3.new(9.63, 0.5, 45.32)
			end
			wait(1)
			end
	end)
end)



Error-- ServerScriptService.Script:13: Expected ')' (to close '(' at line 5), got 'end' - Studio - Script:13

1 answer

✓ Accepted answer

You're missing a few ends in your code. Also, add a wait after or between the loop, so you don't crash. This is the corrected version:

local ToolName = "FlashLight"

while true do
	wait(2)-- change the amount of secs you want it to wait
	game.Players.PlayerAdded:Connect(function(Player)
		Player.CharacterAdded:Connect(function(Character)
			if Player.Backpack:FindFirstChild(ToolName) then
				workspace.BARRIER.Position = Vector3.new(20, 0.5, 45.32)
			else
				workspace.BARRIER.Position = Vector3.new(9.63, 0.5, 45.32
		end
	end)
    end)
end


(Edit: - The other wait between the if statement is redundant, consider removing it!)

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